Skip to content

json

encode(val,space,replacer,whitelist) function

Produce a JSON text from a Javascript object. If a record value, at any level, contains a json() method, it will be called, and the value it returns (usually a simpler record) will be JSONified.

If the record does not have a json() method, and if whitelist is a record, then only the keys that are associated with true in the whitelist are included.

If the space input is true, then line breaks and extra whitespace will be included in the text.

decode(text,reviver) function

The text text is parsed, and the resulting value (usually a record or an array) is returned.

The optional reviver input is a method that will be called for every key and value at every level of the result. Each value will be replaced by the result of the reviver function. This can be used to reform data-only records into method-bearing records, or to transform date strings into seconds.