JSON (JavaScript Object Notation) is a compact, portable, standard data representation
language. See JSON.org. It represents
arrays as comma-separated values within brackets, and records as colon
and comma-separated name:
value pairs within braces.
use json
Misty also provides a JSON
record that contains functions
that process JSON text strictly. Strict JSON has better security and interoperability
properties.
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.
assign my_data: json.decode( text ƒ (key, value) ( key.find("date") then time.number(value) else value ) )
Produce a JSON text from a Misty value. 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.
var my_text: json.encode( my_data ƒ (key, value) ( key.find("date") then time.text(value) else value ) )