Opendylan library to parse the JSON standard file format.
Add json
to your project dependencies
"dependencies": [ "json" ],
Update the dependencies:
dylan update
Add use json;
in the library and module section of your
library.dylan
file.
This library exports the following methods:
parse-json
andprint-json
An example of usage of parse-json
:
let json = """
{
"a": 1,
"b": 2
}
""";
let json-table = parse-json(json);
format-out("a = %d", json-table["a"]);
Run this code in https://play.opendylan.org
print-json
is used to pretty print a table
in JSON format,
following the previous example:
print-json(json-table, *standard-output*, indent: 2);