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).
None except Lua 5.3.
> 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}}
For a full-featured, pure Lua + LPeg JSON encoder / decoder, check out luajson.
Otherwise, there are plenty of options in LuaRocks.
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.