json.decode

Parses JSON text.

Syntax

Signature
json.decode(Text: string) -> any

Aliases

  • json.parse

Parameters

ParameterTypeDescription
TextstringJSON text to parse.

Returns

TypeDescription
anyDecoded 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))