json.decode
Parses JSON text.
Syntax
Signature
json.decode(Text: string) -> anyAliases
json.parse
Parameters
| Parameter | Type | Description |
|---|---|---|
Text | string | JSON text to parse. |
Returns
| Type | Description |
|---|---|
any | Decoded value. JSON null is represented by json.null. |
Notes
JSON objects and arrays become tables, numbers become Luau numbers, and null becomes json.null. Decoded tables keep an array/object marker so empty arrays can be encoded again correctly. Invalid JSON and inputs over 16 MiB raise errors.
Example
Luau
local Settings = json.decode(
'{"enabled":true,"tags":["first","second"],"value":null}'
)
print(Settings.enabled)
for _, Tag in Settings.tags do
print(Tag)
end
assert(json.isnull(Settings.value))