Ballerina API Documentation

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 NameData TypeDescription
jjsonA JSON array object
jsonPathstringThe path of the JSON element
valuebooleanA 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 NameData TypeDescription
jjsonA JSON array object
jsonPathstringThe path of the JSON element
valuestringA 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 NameData TypeDescription
jjsonA JSON object
jsonPathstringThe path of the JSON element
keystringThe name of the element to be added
valuestringA 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 NameData TypeDescription
jjsonA JSON array object
jsonPathstringThe path of the JSON element
valueintAn 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 NameData TypeDescription
jjsonA JSON object
jsonPathstringThe path of the JSON element
keystringThe name of the element to be added
valuejsonA 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 NameData TypeDescription
jjsonA JSON object
jsonPathstringThe path of the JSON element
keystringThe name of the element to be added
valueintAn 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 NameData TypeDescription
jjsonA JSON array object
jsonPathstringThe path of the JSON element
valuefloatA 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 NameData TypeDescription
jjsonA JSON array object
jsonPathstringThe path of the JSON element
valuedoubleA 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 NameData TypeDescription
jjsonA JSON object
jsonPathstringThe path of the JSON element
keystringThe name of the element to be added
valuedoubleA 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 NameData TypeDescription
jjsonA JSON array object
jsonPathstringThe path of the JSON element
valuejsonThe 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 NameData TypeDescription
jjsonA JSON object
jsonPathstringThe path of the JSON element
keystringThe name of the element to be added
valuefloatA 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 NameData TypeDescription
jjsonA JSON object
jsonPathstringThe path of the JSON element
keystringThe name of the element to be added
valuebooleanA Boolean value

function getBoolean(json j, string jsonPath) (boolean )

Evaluates the JSONPath on a JSON object and returns the Boolean value.

Parameters:

Parameter NameData TypeDescription
jjsonA JSON object
jsonPathstringThe path of the JSON element

Return Parameters:

Return VariableData TypeDescription
booleanThe 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 NameData TypeDescription
jjsonA JSON object
jsonPathstringThe path of the JSON element

Return Parameters:

Return VariableData TypeDescription
doubleThe 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 NameData TypeDescription
jjsonA JSON object
jsonPathstringThe path of the JSON element

Return Parameters:

Return VariableData TypeDescription
floatThe 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 NameData TypeDescription
jjsonA json object
jsonPathstringThe path of the JSON element

Return Parameters:

Return VariableData TypeDescription
intThe 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 NameData TypeDescription
jjsonA JSON object
jsonPathstringThe path of the JSON element

Return Parameters:

Return VariableData TypeDescription
jsonThe 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 NameData TypeDescription
jjsonA JSON object
jsonPathstringThe path of the JSON element

Return Parameters:

Return VariableData TypeDescription
stringThe string element on the specified path

function remove(json j, string jsonPath)

Removes each element that matches the given JSONPath.

Parameters:

Parameter NameData TypeDescription
jjsonA JSON object
jsonPathstringThe 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 NameData TypeDescription
jjsonA JSON object
jsonPathstringThe path of the JSON element
oldKeystringThe old key value
newKeystringThe 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 NameData TypeDescription
jjsonA JSON object
jsonPathstringThe path of the JSON element
valuedoubleA 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 NameData TypeDescription
jjsonA JSON object
jsonPathstringThe path of the JSON element
valueintAn 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 NameData TypeDescription
jjsonA JSON object
jsonPathstringThe path of the JSON element
valuestringA 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 NameData TypeDescription
jjsonA JSON object
jsonPathstringThe path of the JSON element
valuejsonA 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 NameData TypeDescription
jjsonA JSON object
jsonPathstringThe path of the JSON element
valuefloatA 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 NameData TypeDescription
jjsonA JSON object
jsonPathstringThe path of the JSON element
valuebooleanA Boolean value

function toString(json j) (string )

Converts a JSON object to a string representation

Parameters:

Parameter NameData TypeDescription
jjsonA JSON object

Return Parameters:

Return VariableData TypeDescription
stringString value of the converted JSON


Menu

  • Functions
    • add(json j, string jsonPath, boolean value)
    • add(json j, string jsonPath, string value)
    • add(json j, string jsonPath, string key, string value)
    • add(json j, string jsonPath, int value)
    • add(json j, string jsonPath, string key, json value)
    • add(json j, string jsonPath, string key, int value)
    • add(json j, string jsonPath, float value)
    • add(json j, string jsonPath, double value)
    • add(json j, string jsonPath, string key, double value)
    • add(json j, string jsonPath, json value)
    • add(json j, string jsonPath, string key, float value)
    • add(json j, string jsonPath, string key, boolean value)
    • getBoolean(json j, string jsonPath) (boolean )
    • getDouble(json j, string jsonPath) (double )
    • getFloat(json j, string jsonPath) (float )
    • getInt(json j, string jsonPath) (int )
    • getJson(json j, string jsonPath) (json )
    • getString(json j, string jsonPath) (string )
    • remove(json j, string jsonPath)
    • rename(json j, string jsonPath, string oldKey, string newKey)
    • set(json j, string jsonPath, double value)
    • set(json j, string jsonPath, int value)
    • set(json j, string jsonPath, string value)
    • set(json j, string jsonPath, json value)
    • set(json j, string jsonPath, float value)
    • set(json j, string jsonPath, boolean value)
    • toString(json j) (string )

Copyright 2017 Ballerina API Documentation