Syntax
json.decode(json: string, options?: DecodeOptions): anyArguments
| Name | Type | Description |
|---|---|---|
json | string | JSON string to parse, format, minify, or validate. |
options? | DecodeOptions | Optional settings table that controls how the operation behaves. |
Returns
| Name | Type | Description |
|---|---|---|
decoded | any | Decoded Luau value or decoded byte string. |
Description
Parses a JSON string and returns the matching Luau value.
Call it with 2 parameter(s): json, options. The argument table explains which values are required and which ones only refine the behavior.
It returns decoded (any). Use the returns table to separate successful values from nil results and recoverable errors.
Example
Decode valid JSON into Luau values.
local value = json.decode('{"name":"Real","enabled":true}')
print(value.name)
print(value.enabled)Types
DecodeOptions
Controls JSON parsing behavior.
useNull? boolean Represents JSON null with the library's null sentinel instead of nil.maxDepth? integer Sets the maximum nesting depth, clamped from 1 to 4096.