Lua · Variables · Storage and web
json
Turn tables into JSON text and back.
| Function | What it does |
|---|---|
json.encode(value) | A table, string, number or boolean as JSON text. A table with keys 1..n becomes an array; others become objects (keys that are not strings are dropped). Up to 16 levels deep. |
json.decode(text) | JSON text as Lua values. nil when the text is not valid JSON. |
#json.encode
json.encode(value)A table, string, number or boolean as JSON text. A table with keys 1..n becomes an array; others become objects (keys that are not strings are dropped). Up to 16 levels deep.
Returns
string
-
Example
print(json.encode({ kills = 3, names = { "a", "b" } }))#json.decode
json.decode(text)JSON text as Lua values. nil when the text is not valid JSON.
Returns
any | nil
-