Skip to main content

getObject (Function)

Function retrieves the object specified in the given path of the JSON element.

Syntax

<OBJECT> json:getObject(<STRING|OBJECT> json, <STRING> path)

Query Parameters

NameDescriptionDefault ValuePossible Data TypesOptionalDynamic
jsonThe JSON input containing the object.STRING OBJECTNoYes
pathThe JSON path to fetch the object.STRINGNoYes

Example 1

json:getObject(json,'$.address')

If the json is the format {'name' : 'John', 'address' : {'city' : 'NY', 'country' : 'USA'}}, the function returns {'city' : 'NY', 'country' : 'USA'} as there is a matching object at $.address.

Example 2

json:getObject(json,'$.age')

If the json is the format {'name' : 'John', 'age' : 23}, the function returns 23 as there is a matching object at $.age.

Example 3

json:getObject(json,'$.salary')

If the json is the format {'name' : 'John', 'age' : 23}, the function returns null as there are no matching element at $.salary.