Module json

A simple, compliant JSON parser and serializer for Lily.

Enums

Value A value of a valid JSON datatype.

Exceptions

JSONSyntaxError An error in JSON data being parsed.

Functions

define parse(json: String, comments: *Boolean, trailing_commas: *Boolean, non_finite: *Boolean): Value

Parses JSON data contained in a String into a Value.

lily-json supports some optional extensions to the JSON syntax, which are configurable through keyword arguments (and enabled by default):

- comments: Allow // ... and /* ... */ comments.

- trailing_commas: Allow objects and arrays to be closed after commas (eg. {"a": 1, "b": 2, "c": 3,} or [1, 2, 3,]).

- non_finite: Treat non-finite floating-point values (Infinity, -Infinity, and NaN) as valid number literals.

define parse_file(path: String, comments: *Boolean, trailing_commas: *Boolean, non_finite: *Boolean): Value

Utility function to read and parse JSON data from a file into a Value.

The optional keyword arguments here function identically to parse's.