Skip to content

Latest commit

 

History

History
58 lines (39 loc) · 962 Bytes

README.md

File metadata and controls

58 lines (39 loc) · 962 Bytes

JSON

Opendylan library to parse the JSON standard file format.

Install

Add json to your project dependencies

"dependencies": [ "json" ],

Update the dependencies:

dylan update

Usage

Add use json; in the library and module section of your library.dylan file.

This library exports the following methods:

  • parse-json and
  • print-json

Parse 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

print-json is used to pretty print a table in JSON format, following the previous example:

print-json(json-table, *standard-output*, indent: 2);

Run a complete example in https://play.opendylan.org