Ballerina API Documentation

Functions of ballerina.lang.jsons package

function addToArray(json j, string jsonPath, any 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
valueanyA any value

function addToObject(json j, string jsonPath, string key, any 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
valueanyA any 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 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, any 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
valueanyAn any 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
    • addToArray(json j, string jsonPath, any value)
    • addToObject(json j, string jsonPath, string key, any value)
    • getBoolean(json j, string jsonPath) (boolean )
    • 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, any value)
    • toString(json j) (string )

Copyright 2017 Ballerina API Documentation