# README

json GoDoc

Usage

local json = require("json")
local inspect = require("inspect")

-- json.encode()
local jsonString = [[
    {
        "a": {"b":1}
    }
]]
local result, err = json.decode(jsonString)
if err then error(err) end
local result = inspect(result, {newline="", indent=""})
if not(result == "{a = {b = 1}}") then error("json.encode") end

-- json.decode()
local table = {a={b=1}}
local result, err = json.encode(table)
if err then error(err) end
local result = inspect(result, {newline="", indent=""})
if not(result == [[{"a":{"b":1}}]]) then error("json.decode") end

# Functions

Decode lua json.decode(string) returns (table, err).
Encode lua json.encode(obj) returns (string, err).
Loader is the module loader function.
Preload adds json to the given Lua state's package.preload table.
ValueDecode converts the JSON encoded data to Lua values.
ValueEncode returns the JSON encoding of value.