Arguments
string
required
JSON text to parse. This argument is checked as a string before parse errors are caught.
DecodeOptions
Optional decode options. A boolean sets useNull directly. A table can set useNull and maxDepth; maxDepth is clamped from 1 to 4096. Invalid option argument types are checked before parse errors are caught.
Returns
boolean
True when parsing succeeds, false when the parser reports an error.
any | nil
Decoded value on success, nil on parse failure. Valid JSON false returns success as true and decoded as false, so check the success return value.
string | nil
Error message on parse failure, otherwise nil. The message includes the json.decodeSafe prefix and parser position.
number | nil
Parser byte position on parse failure, otherwise nil.