FromJSON: Difference between revisions
Jump to navigation
Jump to search
Update Lua API reference |
Complete Lua function catalog |
||
| Line 33: | Line 33: | ||
* JSON is limited to 16 KiB, 16 nested levels, and 2048 entries. | * JSON is limited to 16 KiB, 16 nested levels, and 2048 entries. | ||
[[Category:Lua Functions]] | |||
[[Category:Shared Functions]] | [[Category:Shared Functions]] | ||
[[Category:Utility Functions]] | [[Category:Utility Functions]] | ||
Revision as of 09:52, 15 August 2026
fromJSON
Parses bounded JSON into Lua values.
Syntax
mixed|false value, string|nil error = fromJSON(string json)
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
json |
string |
yes | A UTF-8 JSON document up to 16 KiB. |
Returns
Returns the decoded value and nil on success. On failure it returns false and an error string.
Examples
Decode a JSON payload safely:
local value, errorMessage = fromJSON(payload)
if value == false then
outputDebugString(errorMessage)
else
outputDebugString(tostring(value.ready))
end
Notes
- Available in both server-side and client-side resource scripts.
- JSON is limited to 16 KiB, 16 nested levels, and 2048 entries.