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:Error
value.
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:Error
value.
parseStream
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
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
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
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
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
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
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: 7 months ago
Version: 0.1.0
License: Apache-2.0
Compatibility
Platform: java17
Ballerina version: 2201.9.0
GraalVM compatible: Yes
Pull count
Total: 471
Current verison: 401
Weekly downloads
Keywords
json
json path
json-transform
json transform
json to json
json-convert
json convert
Contributors
Other versions
0.1.0