LibJSON-1.0
LibJSON-1.0 is a library to convert between Lua objects and serialized JSON objects
This is mostly useful if you are exporting lua data to external applications.
local LibJSON = LibStub("LibJSON-1.0")
local myObject = {
alpha = "Hello",
bravo = {1234, 5678.9},
charlie = {delta = "echo"},
delta = LibJSON.Null()
}
local json = LibJSON.Serialize(myObject)
assert(json == [=[{"alpha":"Hello","bravo":[1234,5678.9],"charlie":{"delta":"echo"},"delta":null}]=])
-- and deserializing
local lua = LibJSON.Deserialize([=[{
"alpha": "Hello",
"bravo": [1234, 5678],
"charlie": {"delta": "echo"},
"delta": null
}]=])
assert(lua.charlie.delta == "echo")
assert(lua.bravo[2] == 5678.9)
UTF-8 strings up to U+FFFF are fully supported.
Comments