Skip to main content

Arguments

string
required
JSON string to validate. The function reads this argument with string type checking.
DecodeOptions
Optional decode options. A boolean sets useNull. A table can set useNull and maxDepth. maxDepth is clamped from 1 to 4096.

Returns

boolean
true when parsing one complete JSON value succeeds. false when parsing fails inside the protected parse block.
string | nil
Error message on parse failure. The message is prefixed with json.validate and includes a near-position suffix. This return is only present on failure.
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

Check whether a string contains exactly one complete JSON value.