Skip to main content

参数

string
必填
要 parse 的 JSON string。function 使用 string type checking 读取这个 argument。
DecodeOptions
Optional decode options。boolean 设置 useNull。table 可以设置 useNull 和 maxDepth。

返回值

boolean
parsing 成功时为 true,在 protected parse block 内 parsing 失败时为 false。
any | nil
success 时的 decoded value。parse failure 时此 return 为 nil。
string | nil
parse failure 时的 error message。Message 以 json.decodeSafe 为 prefix,并包含 near-position suffix。
number | nil
parse failure 时 parser 的 parser byte position。此 return 只在 failure 时存在。

类型

DecodeOptions

控制 JSON 解析行为。

示例

使用 json.decodeSafe-compatible alias 以 status returns decode JSON。