Module Standards.JSON5
- Description
Tools for handling the JSON5 structured data format. See http://www.json5.org/ and RFC 4627.
- Constant
ASCII_ONLY
Constant HUMAN_READABLE
Constant PIKE_CANONICAL
Constant UNQUOTED_IDENTIFIERS
Constant SINGLE_QUOTED_STRINGS
constant
Standards.JSON5.ASCII_ONLY
constant
Standards.JSON5.HUMAN_READABLE
constant
Standards.JSON5.PIKE_CANONICAL
constant
Standards.JSON5.UNQUOTED_IDENTIFIERS
constant
Standards.JSON5.SINGLE_QUOTED_STRINGS
- Description
Bit field flags for use with encode:
- Standards.JSON5.ASCII_ONLY
Use
\uxxxx
escapes for all non-ascii characters and DEL (U+007f). The default is to escape only the characters that must be escaped. The flag value is 1.Characters above U+FFFF are encoded using escaped surrogate pairs, as per RFC 4627.
- Standards.JSON5.HUMAN_READABLE
Pretty print with indentation to make the result easier on human eyes. The default is to use no extra whitespace at all. The flag value is 2.
- Standards.JSON5.PIKE_CANONICAL
Make the output canonical, so that the same value always generates the same char-by-char equal string. In practice this means that mapping elements are sorted on their indices. Note that the other flags take precedence, so e.g. the canonical form with HUMAN_READABLE is not the same as the canonical form without it. The flag value is 4.
This canonical form is stable for the encode function, providing floats aren't used (their formatting is currently affected by float size and libc formatting code). In the future there may be a standardized canonical form which quite likely will be different from this one. In that case a separate flag has to be added so this one doesn't change - hence the name PIKE_CANONICAL.
- Standards.JSON5.UNQUOTED_IDENTIFIERS
When producing mapping keys, permit keys which are identifiers to be expressed without surrounding quotation marks.
- Standards.JSON5.SINGLE_QUOTED_STRINGS
Use single quotation marks rather than double quotation marks when encoding string values.