Skip to main content

jsonParse

jsonParse ( jsonString : string , type : integer {, *} ) : any

ParameterTypeDescription
jsonStringstring->JSON string to parse
typeinteger->Type in which to convert the values
*->Adds line position and offset of each property if returned value is an object
Resultany<-Values extracted from JSON string

Description

The jsonParse command parses the contents of a JSON-formatted string and extracts values that you can store in a Qodly field or variable.

In jsonString, pass the JSON-formatted string whose contents you want to parse. This string must be formatted correctly, otherwise a parsing error is generated. jsonParse can therefore be used to validate JSON strings.

note

If you use pointers, you must call the jsonStringify command before calling jsonParse.

By default, if you omit the type parameter, Qodly attempts to convert the value obtained into the type of the variable or attribute used to store the results (if one is defined). Otherwise, Qodly attempts to infer its type. You can also force the type interpretation by passing one of the following constants in the type parameter:

ConstantTypeValue
kBooleaninteger6
kCollectioninteger42
kDateinteger4
kIntegerinteger9
kObjectinteger38
kNumberinteger1
kStringinteger2
kTimeinteger11

If you pass the * optional parameter and if the jsonString parameter represents an object, the returned object contains an additional property named __symbols that provides path, line position, and line offset of each property and sub-property of the object. This information can be useful for debugging purposes. The structure of the __symbols property is:

__symbols:{//object description
myAtt.mySubAtt...:{ //property path
line:10, //line number of the property
offset:35 //offset of the property from the beginning of the line } }
note

The * parameter is ignored if the returned value is not of the object type.

See also

jsonStringify
jsonValidate