Module:JSON/documentation

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 ofModule:JSON/documentation, as well as those of other words, enriches your vocabulary and provides you with more and better linguistic resources.

This module offers some utility methods for converting Lua values into JSON values (in UTF-8-encoded Lua strings).

Unfortunately, Lua's data model differs somewhat from JSON's, so it's not possible to write a general function that takes any Lua value and returns a JSON value, always "doing the right thing". Rather, some values cannot be converted at all, and other values have multiple possible non-equivalent representations.

The differences are:

  • 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 concept of "metatables" has no analogue in JSON, so this module ignores metatables completely.
  • Lua's number type, as implemented in Scribunto, consists of double-precision floating-point values, whereas JSON's number type consists of decimal representations. (And the end-recipient of the JSON data will likely convert the values back into some sort of floating-point notation.) This means that, aside from integers, you can't generally expect values to be converted exactly. (And even with integers, you can only expect perfect conversion in the range ±109 or so.) What's more, it means that Lua has a few numeric values with no JSON analogues at all, namely positive infinity, negative infinity, and "not a number" values; so, this module does not support those values.
  • Lua's string type represents strings of eight-bit bytes, whereas JSON's *string* type represents strings of Unicode characters. This module requires the Lua strings to be valid UTF-8 sequences.
  • Whereas Lua has only 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. As a result, this module

(Note: the above is an attempt at an exhaustive list of differences, but it's quite possible that I missed some.)