Added in v3.18


Syntax: %json(var)
Syntax: %json(string)

When a variable name is given, this function returns the JSON string format of the string list or database variable/table. If a string argument is given, this function will construct the corresponding string list or database table from the JSON data string.


#ADDKEY dbvar Name Zugg
#ADDKEY dbvar Level 20
#SHOW %json(@dbvar)

Displays: {"Level":20,"Name":"Zugg"}

db = %json("{""Level"":20,""Name"":""Zugg""}")
#SHOW @db.Name

Displays: "Zugg". Note that when specifying a json string directly, the " quotes within the string need to be doubled so that they are properly passed to the %json function. If the string data came from some other source, such as from a web service, no doubling of quotes is needed.

Add comment

Login or register to post comments