data.jsondata
Module data.jsondata
ballerina/data.jsondata Ballerina library
Functions![](/images/permalink.svg)
parseAsType![](/images/permalink.svg)
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:Error
value.
parseBytes![](/images/permalink.svg)
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:Error
value.
parseStream![](/images/permalink.svg)
function parseStream(stream<byte[], error?> s, Options options, typedesc<anydata> t) returns t|Error
Converts 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:Error
value.
parseString![](/images/permalink.svg)
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:Error
value.
prettify![](/images/permalink.svg)
Prettifies a json
value to print it.
Parameters
- value json - The
json
value to be prettified
- indentation int (default 4) - The number of spaces for an indentation
Return Type
- string - The prettified
json
as a string
read![](/images/permalink.svg)
function read(json 'json, JsonPathRawTemplate query) returns json|Error
Extract 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![](/images/permalink.svg)
function toJson(anydata v) returns json|Error
Converts a value of type anydata
to json
.
Parameters
- v anydata - Source anydata value
Return Type
- json|Error - representation of
v
as value of type json
Annotations![](/images/permalink.svg)
data.jsondata: Name![](/images/permalink.svg)
The annotation is used to overwrite the existing record field name.
Records![](/images/permalink.svg)
data.jsondata: NameConfig![](/images/permalink.svg)
Defines the name of the JSON Object key.
Fields
- value string - The name of the JSON Object key
data.jsondata: Options![](/images/permalink.svg)
Represent the options that can be used to modify the behaviour of the projection.
Fields
Errors![](/images/permalink.svg)
data.jsondata: Error![](/images/permalink.svg)
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![](/images/permalink.svg)
data.jsondata: JsonPathRawTemplate![](/images/permalink.svg)
Fields
- Fields Included from *RawTemplate
- strings string[] & readonly -
- insertions JsonPathValue[] -
Import
import ballerina/data.jsondata;
Metadata
Released date: 4 months ago
Version: 0.1.0
License: Apache-2.0
Compatibility
Platform: java17
Ballerina version: 2201.9.0
GraalVM compatible: Yes
Pull count
Total: 25
Current verison: 24
Weekly downloads
Keywords
json
json path
json-transform
json transform
json to json
json-convert
json convert
Contributors
Other versions
0.1.0