lson: JSON+ de/serializer in pure lua

This folder defines an LSON spec and an example public domain pure-lua implementation of LSON/JSON encoder and decoder.

Lua Library

lson is a pure-lua JSON+ de/serialization library. The main functions are the encoding functions json() and lson() and the decode() function (which decodes either encoder's output).

See also the types Json , Lson and Decoder and their documentation to have more control of the usage, including pretty printing and a decoding iterator.

Note: If you want highly performant or compliant JSON library then use a different one. This library is part of the civlua project and is optimized for simplicy and improved features.

LSON

LSON is a strict superset of JSON: all valid JSON is valid LSON but not vice versa. The difference is:

LSON ignores commas (it treats them as whitespace). List and map entries can be separated by any whitespace (including commas). This makes it easier for a human to write and vcs to diff.

LSON adds binary syntax for bytes |any binary data| . The data within |...| is arbitrary bytes except the following will be converted: \\ -> \ , \| -> | ,

-> newline Other "escapes" are preserved, i.e. \d -> \d This makes encoding binary data in LSON MUCH more compact (and possible) than JSON.

LICENSE

This library and spec are public domain. See UNLICENSE in the repo root.