Json Modules

lua-users home
wiki

JSON (JavaScript? Object Notation) is a format for serializing data based on the format for JavaScript? data structures. For more informations about JSON in general see http://www.json.org/ and [the Wikipedia article on JSON].

A comparison of JSON modules

Since some modules were only called "json" initials were added to create unique names:

This comparison was done by DavidKolf, author of dkjson. It might be biased toward my design goals.

For comparison the default options were used. I expect a module to be JSON-compliant with the default settings. An exception was made for Fleece, most of this comparison wouldn't make sense for anything other than the option "E4".

The [feature/compliance tests] and the [speed test] can be found in the repository for dkjson.

Further JSON implementations

JSON implementations that are not included in this comparison (yet):

Major bugs

Escaped characters when encoding

Support for unicode escape sequences \uXXXX when decoding

Other bugs

Edge cases for encoding

JSON cannot represent every Lua structure. This section lists the behavior for some cases. You shouldn't feed any data like this to any JSON module but it's still interesting how the modules handle this. A module must not hang or crash and it should not produce invalid JSON output. (Raising Lua errors is a valid way to deal with such data).

Mixed tables

{[1] = 1, a = 2}

Sparse arrays

{[1000] = "test"}

Handling of NaN and Inf

nan = math.huge * 0
inf = math.huge

Protection against reference cycles when encoding

a = {}
a.a = a

Encoding speed

Decoding speed

For the speed tests a table was encoded or decoded 100000 times. The values are not precise and might differ when using other data, but they should give a general orientation.

See Also


RecentChanges · preferences
edit · history
Last edited August 10, 2011 4:27 am GMT (diff)