Functions of ballerina.lang.jsons package
function add(json j, string jsonPath, boolean value)
Inserts a Boolean to a JSON array. This function will add a new Boolean element to the end of the JSON array identified by the given JSONPath.
Parameters:
Parameter Name | Data Type | Description |
---|---|---|
j | json | A JSON array object |
jsonPath | string | The path of the JSON element |
value | boolean | A Boolean value |
function add(json j, string jsonPath, string value)
Inserts an element to a JSON array. This function will add a new string element to the end of the JSON array identified by the given JSONPath.
Parameters:
Parameter Name | Data Type | Description |
---|---|---|
j | json | A JSON array object |
jsonPath | string | The path of the JSON element |
value | string | A string value |
function add(json j, string jsonPath, string key, string value)
Inserts a named element to a JSON object. This function will add a new string element with the given name (key)
Parameters:
Parameter Name | Data Type | Description |
---|---|---|
j | json | A JSON object |
jsonPath | string | The path of the JSON element |
key | string | The name of the element to be added |
value | string | A string value |
function add(json j, string jsonPath, int value)
Inserts an integer element to a JSON array. This function will add a new integer element to the end of the JSON array identified by the given JSONPath.
Parameters:
Parameter Name | Data Type | Description |
---|---|---|
j | json | A JSON array object |
jsonPath | string | The path of the JSON element |
value | int | An integer value |
function add(json j, string jsonPath, string key, json value)
Inserts a named element to a JSON object. This method will add a new JSON element with the given name (key)
Parameters:
Parameter Name | Data Type | Description |
---|---|---|
j | json | A JSON object |
jsonPath | string | The path of the JSON element |
key | string | The name of the element to be added |
value | json | A JSON value |
function add(json j, string jsonPath, string key, int value)
Inserts a named element to a JSON object. This function will add a new integer element with the given name (key)
Parameters:
Parameter Name | Data Type | Description |
---|---|---|
j | json | A JSON object |
jsonPath | string | The path of the JSON element |
key | string | The name of the element to be added |
value | int | An integer value |
function add(json j, string jsonPath, float value)
Inserts a float to a JSON array. This function will add a new float element to the end of the JSON array identified by the given JSONPath.
Parameters:
Parameter Name | Data Type | Description |
---|---|---|
j | json | A JSON array object |
jsonPath | string | The path of the JSON element |
value | float | A float value |
function add(json j, string jsonPath, double value)
Inserts a double to a JSON array. This function will add a new double value to the end of the JSON array identified by the given JSONPath.
Parameters:
Parameter Name | Data Type | Description |
---|---|---|
j | json | A JSON array object |
jsonPath | string | The path of the JSON element |
value | double | A double value |
function add(json j, string jsonPath, string key, double value)
Inserts a named element to a JSON object. This function will add a new double element with the given name (key) to the location identified by the given JSONPath. If an element with the same name already exists, it will update the value of the existing element.
Parameters:
Parameter Name | Data Type | Description |
---|---|---|
j | json | A JSON object |
jsonPath | string | The path of the JSON element |
key | string | The name of the element to be added |
value | double | A double value |
function add(json j, string jsonPath, json value)
Inserts a JSON element to a JSON array. This function will add a new JSON element to the end of the JSON array identified by the given JSONPath.
Parameters:
Parameter Name | Data Type | Description |
---|---|---|
j | json | A JSON array object |
jsonPath | string | The path of the JSON element |
value | json | The JSON element to be added |
function add(json j, string jsonPath, string key, float value)
Inserts a named element to a JSON object. This function will add a new float element with the given name (key)
Parameters:
Parameter Name | Data Type | Description |
---|---|---|
j | json | A JSON object |
jsonPath | string | The path of the JSON element |
key | string | The name of the element to be added |
value | float | A float value |
function add(json j, string jsonPath, string key, boolean value)
Inserts a named element to a JSON object. This function will add a new Boolean element with the given name (key) to the location identified by the given JSONPath.
Parameters:
Parameter Name | Data Type | Description |
---|---|---|
j | json | A JSON object |
jsonPath | string | The path of the JSON element |
key | string | The name of the element to be added |
value | boolean | A Boolean value |
function getBoolean(json j, string jsonPath) (boolean )
Evaluates the JSONPath on a JSON object and returns the Boolean value.
Parameters:
Parameter Name | Data Type | Description |
---|---|---|
j | json | A JSON object |
jsonPath | string | The path of the JSON element |
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
boolean | The Boolean element on the specified path |
function getDouble(json j, string jsonPath) (double )
Evaluates the JSONPath on a JSON object and returns the double value.
Parameters:
Parameter Name | Data Type | Description |
---|---|---|
j | json | A JSON object |
jsonPath | string | The path of the JSON element |
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
double | The double element on the specified path |
function getFloat(json j, string jsonPath) (float )
Evaluates the JSONPath on a JSON object and returns the integer value.
Parameters:
Parameter Name | Data Type | Description |
---|---|---|
j | json | A JSON object |
jsonPath | string | The path of the JSON element |
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
float | The float element on the specified path |
function getInt(json j, string jsonPath) (int )
Evaluates the JSONPath on a JSON object and returns the integer value.
Parameters:
Parameter Name | Data Type | Description |
---|---|---|
j | json | A json object |
jsonPath | string | The path of the JSON element |
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
int | The integer element on the specified path |
function getJson(json j, string jsonPath) (json )
Evaluates the JSONPath on a JSON object and returns the matching JSON.
Parameters:
Parameter Name | Data Type | Description |
---|---|---|
j | json | A JSON object |
jsonPath | string | The path of the JSON element |
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
json | The JSON element on the specified path |
function getString(json j, string jsonPath) (string )
Evaluates the JSONPath on a JSON object and returns the string value
Parameters:
Parameter Name | Data Type | Description |
---|---|---|
j | json | A JSON object |
jsonPath | string | The path of the JSON element |
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
string | The string element on the specified path |
function remove(json j, string jsonPath)
Removes each element that matches the given JSONPath.
Parameters:
Parameter Name | Data Type | Description |
---|---|---|
j | json | A JSON object |
jsonPath | string | The path of the JSON element |
function rename(json j, string jsonPath, string oldKey, string newKey)
Renames the key of the given element that is under the given JSONPath.
Parameters:
Parameter Name | Data Type | Description |
---|---|---|
j | json | A JSON object |
jsonPath | string | The path of the JSON element |
oldKey | string | The old key value |
newKey | string | The new key value to use |
function set(json j, string jsonPath, double value)
Sets the double value of the element that matches the given JSONPath. If the JSONPath doesn't match any element, this operation will have no effect.
Parameters:
Parameter Name | Data Type | Description |
---|---|---|
j | json | A JSON object |
jsonPath | string | The path of the JSON element |
value | double | A double value |
function set(json j, string jsonPath, int value)
Sets the integer value of the element that matches the given JSONPath. If the JSONPath doesn't match any element, this operation will have no effect.
Parameters:
Parameter Name | Data Type | Description |
---|---|---|
j | json | A JSON object |
jsonPath | string | The path of the JSON element |
value | int | An integer value |
function set(json j, string jsonPath, string value)
Sets the string value of the element that matches the given JSONPath. If the JSONPath doesn't match any element, this operation will have no effect.
Parameters:
Parameter Name | Data Type | Description |
---|---|---|
j | json | A JSON object |
jsonPath | string | The path of the JSON element |
value | string | A string value |
function set(json j, string jsonPath, json value)
Sets the JSON value of the element that matches the given JSONPath. If the JSONPath doesn't match any element, this operation will have no effect.
Parameters:
Parameter Name | Data Type | Description |
---|---|---|
j | json | A JSON object |
jsonPath | string | The path of the JSON element |
value | json | A JSON value |
function set(json j, string jsonPath, float value)
Sets the float value of the element that matches the given JSONPath. If the JSONPath doesn't match any element, this operation will have no effect.
Parameters:
Parameter Name | Data Type | Description |
---|---|---|
j | json | A JSON object |
jsonPath | string | The path of the JSON element |
value | float | A float value |
function set(json j, string jsonPath, boolean value)
Sets the Boolean value of the element that matches the given JSONPath. If the JSONPath doesn't match any element, this operation will have no effect.
Parameters:
Parameter Name | Data Type | Description |
---|---|---|
j | json | A JSON object |
jsonPath | string | The path of the JSON element |
value | boolean | A Boolean value |
function toString(json j) (string )
Converts a JSON object to a string representation
Parameters:
Parameter Name | Data Type | Description |
---|---|---|
j | json | A JSON object |
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
string | String value of the converted JSON |