json_decode
json_decode(string) parses a JSON string into a native Lua table. Returns (value, nil) on success, or (nil, error_message) on failure.
Signature
Section titled “Signature”json_decode(string)
syncParameters
Section titled “Parameters”| Param | Type | Description |
|---|---|---|
string |
string | The JSON string to parse |
Returns
Section titled “Returns”| Value | Type | Description |
|---|---|---|
| 1st | any / nil | Parsed Lua value, or nil on malformed JSON |
| 2nd | string / nil | Error message, or nil on success |
Example
Section titled “Example”local data, err = json_decode('{"status": "ok", "count": 42}')if not data then log("decode failed: " .. err) returnendlog("Status is: " .. data.status)See Also
Section titled “See Also”- json_encode - Convert Lua table to JSON string