Skip to main content

参数

string
必填
要 validate 的 JSON string。function 使用 string type checking 读取此 argument。
DecodeOptions
Optional decode options。boolean 设置 useNull。table 可以设置 useNull 和 maxDepth。maxDepth 会 clamp 到 1 到 4096。

返回值

boolean
当一个 complete JSON value parsing 成功时为 true。当 parsing 在 protected parse block 中失败时为 false。
string | nil
parse failure 时的 Error message。message 使用 json.validate 作为 prefix,并包含 near-position suffix。此 return 只在 failure 时存在。
number | nil
parse failure 时来自 parser 的 Parser byte position。此 return 只在 failure 时存在。

类型

DecodeOptions

控制 JSON 解析行为。

示例

检查 string 是否正好包含一个 complete JSON value。