enjson(V;O)
Converts values, including packages and lists, into a JSON string. (Available as of version 11.07)
Syntax
enjson(V;O)
Input
Argument | Type | Description |
---|---|---|
V |
any | A value, list, or package to be converted into JSON |
O |
text | One of the following special options: 'noquotekeys' or
'quotekeys'
|
Return Value
Returns a JSON string of the value.
Example
The following code converts a package to a JSON string, and surrounds the keys with double-quote characters (the default option).
<willbe name="package" value="{pkg('a' 'b' 'c';'Larry' 'Curly' 'Moe')}"/>
<willbe name="json" value="enjson(package;)"/>
The resulting JSON string is {"a":"Larry","b":"Curly","c":"Moe"}
The following code converts a package to a JSON string, leaving out the double-quote characters surrounding the keys.
<willbe name="package" value="{pkg('a' 'b' 'c';'Larry' 'Curly' 'Moe')}"/>
<willbe name="jsonnoquotes" value="enjson(package;'noquotekeys')"/>
The resulting JSON string is {a:"Larry",b:"Curly",c:"Moe"}