Module Standards.JSON
- Description
Tools for handling the JSON structured data format. See http://www.json.org/ and RFC 4627.
- Constant
ASCII_ONLY
Constant HUMAN_READABLE
Constant PIKE_CANONICAL
Constant CANONICAL
constant
Standards.JSON.ASCII_ONLY
constant
Standards.JSON.HUMAN_READABLE
constant
Standards.JSON.PIKE_CANONICAL
constant
Standards.JSON.CANONICAL
- Description
Bit field flags for use with encode:
- Standards.JSON.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.JSON.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.JSON.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. See also CANONICAL below.
- Standards.JSON.CANONICAL
Make the output canonical as per RFC 8785, so that the same value always generates the same char-by-char equal string. The flag value is 8.
Note that RFC 8785-compliant output will only be generated if this is the only flag that has been set and no indentation has been requested, and
Pike.get_runtime_info()->float_size == 64
. In other cases a best effort attempt to comply with RFC 8785 will be performed, but deviations may occur.
- Constant
NO_OBJECTS
constant
Standards.JSON.NO_OBJECTS
- Description
Bit field flags for use with decode: