lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


dkjson is a module for encoding and decoding JSON data. It supports UTF-8.

JSON (JavaScript Object Notation) is a format for serializing data based
on the syntax for JavaScript data structures.

dkjson is written in Lua without any dependencies, but
when LPeg is available dkjson uses it to speed up decoding.


<http://chiselapp.com/user/dhkolf/repository/dkjson/>


Changes since version 2.1:

  *  __jsontype is only used for empty tables.
  *  It is possible to decode tables without assigning metatables.
  *  Locations for error messages were off by one in the first line.
  *  There is no LPeg version of json.quotestring anymore.


The main change since the last version is the treatment of the
__jsontype value in the metatable. In previous versions (2.0 and 2.1)
this replaced the usual test for an array and selected the type of the
table directly.

However, I received reports that this caused confusion and undesired
behaviour when for example an empty table got encoded as an array,
decoded with the default metatables, extended with string keys and
encoded again. As the table was forced by the metatable to be encoded as
an array, the new keys were lost.

Now __jsontype is only used for empty tables to decide whether they are
arrays or objects.

Best regards,

David Kolf