Hello, you have come here looking for the meaning of the word
Module:JSON/documentation. In DICTIOUS you will not only get to know all the dictionary meanings for the word
Module:JSON/documentation, but we will also tell you about its etymology, its characteristics and you will know how to say
Module:JSON/documentation in singular and plural. Everything you need to know about the word
Module:JSON/documentation you have here. The definition of the word
Module:JSON/documentation will help you to be more precise and correct when speaking or writing your texts. Knowing the definition of
Module:JSON/documentation, as well as those of other words, enriches your vocabulary and provides you with more and better linguistic resources.
This module converts Lua objects into JSON strings that are compliant with the JSON standard (RFC 7159).
It is not possible to perfectly convert Lua objects to JSON in all cases, but in most cases a close approximation is possible. The main points to note are listed below:
- This module takes objects at face value, and does not attempt to determine the content of metatables. Metamethods will be used, if present.
- Lua has three types with no JSON analogues, namely function, userdata, and thread, so this module has no support for values of those types.
- Lua's
nil
is converted to null
.
- Lua's number type, as implemented in Scribunto, consists of double-precision floating-point values, whereas JSON's number type consists of decimal representations. This module will convert integers between
-(2^53) + 1
and 2^53 - 1
to an integer format, and anything else to a format that uses decimal or scientific notation (i.e. a format that should be interpreted as a float by the other end). The minimum number of significant figures will be used that ensures no loss of precision (up to 17). ±Infinity and NaN cannot be represented in JSON, however.
- Lua's string type represents strings of eight-bit bytes, whereas JSON's string type represents strings of Unicode characters. This module requires strings to be valid UTF-8 sequences.
- Characters may be escaped using one of the escape sequences defined in RFC 7159 (
\"
, \\
, \/
, \b
, \f
, \n
, \r
and \t
), or with \uXXXX
, where XXXX represents a four-digit Unicode codepoint (e.g. \u0160
represents U+0160). Characters with codepoints above U+FFFF may be represented by the escape sequences for the pair of surrogates which are used to represent that character in UTF-16 (e.g. \uD800\uDC00
represents U+10000).
- Lua only has a single table type mapping from arbitrary non-nil values to arbitrary non-nil values, JSON has separate array and object types, where an array maps from a set of integers {0,1,…,n} to arbitrary values, and an object maps from arbitrary strings to arbitrary values. This module will attempt to convert tables to arrays, and will fall back to objects if this is not possible.
- Lua tables can use arbitrary objects as keys, whereas JSON objects only allow strings. Where a table uses numbers or booleans as keys, this function will convert them to strings.