Manipulation of JSON data strings.
decode JSON from a string to a lua-table
Decode a string of JSON data into a Lua table. A Lua error is raised for syntax errors.
json -
string json data
data -
table decoded json
Converting a string containing JSON data into a Lua table:
function init(self) local jsonstring = '{"persons":[{"name":"John Doe"},{"name":"Darth Vader"}]}' local data = json.decode(jsonstring) pprint(data) end
Results in the following printout:
{ persons = { 1 = { name = John Doe, } 2 = { name = Darth Vader, } } }