/json.lua

Lima's version of the JSON wheel.

Primary LanguageLuaMIT LicenseMIT

json.lua

Presentation

This is Lima's version of the JSON wheel. It is a fork of rxi/json.lua.

Typically we only use the encoder with Lua 5.3. Consider other use cases unsupported (see Alternatives).

Dependencies

None except Lua 5.3.

Usage

> json = require "json"
> json.encode({foo = { bar = "baz", answer = 42 }})
{
  "foo":{
    "bar":"baz",
    "answer":42
  }
}
> json.encode({foo = { bar = "baz", answer = 42 }}, false) -- no pretty printing
{"foo":{"bar":"baz","answer":42}}

Alternatives

For a full-featured, pure Lua + LPeg JSON encoder / decoder, check out luajson.

Otherwise, there are plenty of options in LuaRocks.

License

This library is free software; you can redistribute it and/or modify it under the terms of the MIT license. See LICENSE.txt for details.