Skip to main content

Arguments

string
required
JSON string to parse. The function reads this argument with string type checking.
DecodeOptions
Optional decode options. A boolean sets useNull. A table can set useNull and maxDepth.

Returns

boolean
true when parsing succeeds, false when parsing fails inside the protected parse block.
any | nil
Decoded value on success. On parse failure, this return is nil.
string | nil
Error message on parse failure. The message is prefixed with json.decodeSafe and includes a near-position suffix.
number | nil
Parser byte position from the parser on parse failure. This return is only present on failure.

Types

DecodeOptions

Controls JSON parsing behavior.

Example

Decode JSON with status returns using the json.decodeSafe-compatible alias.