data.jsondata
Module data.jsondata
ballerina/data.jsondata Ballerina library
Functions
parseAsType
Convert value of type json to subtype of anydata.
Parameters
- v json - Source JSON value
- options Options (default {}) - Options to be used for filtering in the projection
- t typedesc<anydata> (default <>) - Target type
Return Type
- t|Error - On success, returns value belonging to the given target type, else returns an
jsondata:Errorvalue.
parseBytes
Converts JSON byte[] to subtype of anydata.
Parameters
- s byte[] - Source JSON byte[]
- options Options (default {}) - Options to be used for filtering in the projection
- t typedesc<anydata> (default <>) - Target type
Return Type
- t|Error - On success, value belonging to the given target type, else returns an
jsondata:Errorvalue.
parseStream
function parseStream(stream<byte[], error?> s, Options options, typedesc<anydata> t) returns t|ErrorConverts JSON byte-block-stream to subtype of anydata.
Parameters
- options Options (default {}) - Options to be used for filtering in the projection
- t typedesc<anydata> (default <>) - Target type
Return Type
- t|Error - On success, value belonging to the given target type, else returns an
jsondata:Errorvalue.
parseString
Converts JSON string to subtype of anydata.
Parameters
- s string - Source JSON string value or byte[] or byte-block-stream
- options Options (default {}) - Options to be used for filtering in the projection
- t typedesc<anydata> (default <>) - Target type
Return Type
- t|Error - On success, value belonging to the given target type, else returns an
jsondata:Errorvalue.
prettify
Prettifies a json value to print it.
Parameters
- value json - The
jsonvalue to be prettified
- indentation int (default 4) - The number of spaces for an indentation
Return Type
- string - The prettified
jsonas a string
read
function read(json 'json, JsonPathRawTemplate query) returns json|ErrorExtract details from the given JSON value using the provided query template expression.
read({id: 1, "name": "John Doe"}, `$.name`) => "John Doe"
Return Type
- json|Error - extracted details as JSON value, a jsonpath:Error otherwise
toJson
function toJson(anydata v) returns jsonConverts a value of type anydata to json.
Parameters
- v anydata - Source anydata value
Return Type
- json - representation of
vas value of type json
Annotations
data.jsondata: Name
The annotation is used to overwrite the existing record field name.
Records
data.jsondata: NameConfig
Defines the name of the JSON Object key.
Fields
- value string - The name of the JSON Object key
data.jsondata: Options
Represent the options that can be used to modify the behaviour of the projection.
Fields
- enableConstraintValidation boolean(default true) - Enable or disable constraint validation
Errors
data.jsondata: Error
Represents the error type of the ballerina/data.jsondata module. This error type represents any error that can occur during the execution of jsondata APIs.
Object types
data.jsondata: JsonPathRawTemplate
Fields
- Fields Included from *RawTemplate
- strings string[] & readonly -
- insertions JsonPathValue[] -
Import
import ballerina/data.jsondata;Metadata
Released date: 11 months ago
Version: 1.0.0
License: Apache-2.0
Compatibility
Platform: java21
Ballerina version: 2201.11.0-20241209-162400-0c015833
GraalVM compatible: Yes
Pull count
Total: 0
Current verison: 0
Weekly downloads
Keywords
json
json path
json-transform
json transform
json to json
json-convert
json convert
Contributors