Skip to main content

getBool (Function)

Function retrieves the boolean value specified in the given path of the JSON element.

Syntax

<BOOL> json:getBool(<STRING|OBJECT> json, <STRING> path)

Query Parameters

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

Example 1

json:getBool(json,'$.married')

If the json is the format {'name' : 'John', 'married' : true}, the function returns true as there is a matching boolean at $.married.

Example 2

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

If the json is the format {'name' : 'John', 'married' : true}, the function returns null as there is no matching boolean at $.name.

Example 3

json:getBool(json,'$.foo')

If the json is the format {'name' : 'John', 'married' : true}, the function returns null as there is no matching element at $.foo.