Skip to main content

参数

string
必填
要解析的 JSON text。parser 接受一个带有 optional surrounding whitespace 的 JSON value,并在发现 invalid syntax 或 trailing non-whitespace characters 时抛出错误。
DecodeOptions
Optional decode options。boolean 会直接设置 useNull。table 可以设置 useNull 和 maxDepth;maxDepth 会 clamp 到 1 到 4096。

返回值

any
Decoded value。JSON objects 和 arrays 会变成带有 JSON type markers 的 tables,strings 变成 Lua strings,numbers 变成 Lua numbers,booleans 变成 booleans,null 会变成 json.null,除非 useNull 为 false。

类型

DecodeOptions

控制 JSON 解析行为。

示例

将 JSON decode 为 Lua values,同时保留 JSON array、object 和 null markers。