Skip to main content

getString (Function)

Function retrieves value specified in the given path of the JSON element as a string.

Syntax

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

Query Parameters

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

Example 1

json:getString(json,'$.name')

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

Example 2

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

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

Example 3

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

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

Example 4

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

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