Skip to main content

Arguments

string
required
JSON text to parse. The parser accepts one JSON value with optional surrounding whitespace and throws when invalid syntax or trailing non-whitespace characters are found.
DecodeOptions
Optional decode options. A boolean sets useNull directly. A table can set useNull and maxDepth; maxDepth is clamped from 1 to 4096.

Returns

any
Decoded value. JSON objects and arrays become tables with JSON type markers, strings become Lua strings, numbers become Lua numbers, booleans become booleans, and null becomes json.null unless useNull is false.

Types

DecodeOptions

Controls JSON parsing behavior.

Example

Decode JSON into Lua values while preserving JSON array, object, and null markers.