{ "source": "doc/api/json.markdown", "modules": [ { "textRaw": "JSON", "name": "json", "desc": "
local json = require('json')
\n\n
Alternatively you can use lpeg like so:\n\n
\nlocal json = require('json').use_lpeg()
\n",
"methods": [
{
"textRaw": "json.stringify(value [, state])",
"type": "method",
"name": "stringify",
"desc": "Serialize a Lua table into a JSON string.\n\n
\nlocal tbl = { username = "Groucho" }\nlocal json_str = json.stringify( tbl )
\n",
"signatures": [
{
"params": [
{
"name": "value"
},
{
"name": "state",
"optional": true
}
]
}
]
},
{
"textRaw": "json.encode(value[, state])",
"type": "method",
"name": "encode",
"desc": "Alias for json.stringify\n\n
\n", "signatures": [ { "params": [ { "name": "value" }, { "name": "state", "optional": true } ] } ] }, { "textRaw": "json.parse(str [, pos][, nullval][, ...])", "type": "method", "name": "parse", "desc": "Deserialize a JSON string into a Lua table.\n\n
\nlocal json_str = '{ "username": "Groucho" }'\nlocal tbl = json.parse( json_str )
\n",
"signatures": [
{
"params": [
{
"name": "str"
},
{
"name": "pos",
"optional": true
},
{
"name": "nullval",
"optional": true
},
{
"name": "...",
"optional": true
}
]
}
]
},
{
"textRaw": "json.decode(str[, pos, nullval, ...])",
"type": "method",
"name": "decode",
"desc": "Alias for json.parse\n\n
\n", "signatures": [ { "params": [ { "name": "str" }, { "name": "pos" }, { "name": "nullval" }, { "name": "...", "optional": true } ] } ] }, { "textRaw": "json.quotestring(value)", "type": "method", "name": "quotestring", "desc": "Quotes a string. Based on the regexp "escapable" in https://github.com/douglascrockford/JSON-js\n\n
\n", "signatures": [ { "params": [ { "name": "value" } ] } ] } ], "properties": [ { "textRaw": "Value: json.null", "name": "null", "desc": "A null property type for JSON encoding.\n\n
\nlocal tbl = { user = "Jane", is_working = json.null }\nlocal json_str = json.stringify( tbl )
\n"
}
],
"type": "module",
"displayName": "JSON"
}
]
}