> ## Documentation Index
> Fetch the complete documentation index at: https://docs.projectreal.gg/llms.txt
> Use this file to discover all available pages before exploring further.

# JSON

> 解析、编码、检查和转换 JSON。

<div className="real-category-page">
  解析、编码、检查和转换 JSON。

  ## 可用函数

  <CardGroup cols={2}>
    <Card title="json.array" href="./json-array">
      为 json.encode 创建一个标记为 JSON array 的 new table，并在提供 source table 时复制 1.#source sequence。
    </Card>

    <Card title="json.clone" href="./json-clone">
      通过 json.encode semantics 对 value 进行 encoding，再把 generated JSON decoding 回 Lua values 来 clone。
    </Card>

    <Card title="json.decode" href="./json-decode">
      使用 Real JSON parser 解析 JSON string，并返回 decoded Lua value，同时为 JSON helpers 标记 decoded arrays 和 objects。
    </Card>

    <Card title="json.decodeSafe" href="./json-decodesafe">
      使用与 json.decode 相同的 parser 解析 JSON，并在 parse errors 时返回 success flag，而不是抛出错误。
    </Card>

    <Card title="json.encode" href="./json-encode">
      使用 Real JSON encoder 将 Lua value serialize 为 JSON string。json.stringify 注册到同一个 function。
    </Card>

    <Card title="json.encodePretty" href="./json-encodepretty">
      使用 Real JSON encoder 将 Lua value serializes 为 readable formatted JSON string。json.pretty 注册到同一个 function。
    </Card>

    <Card title="json.escape" href="./json-escape">
      使用 Real JSON string escaping rules 对 string 执行 escape，并返回不带 surrounding quotes 的 escaped content。
    </Card>

    <Card title="json.format" href="./json-format">
      Parse 一个 JSON string，并使用 Real JSON parser 和 encoder 将其 re-encode 为 readable formatted JSON。
    </Card>

    <Card title="json.getPath" href="./json-getpath">
      使用 dotted string path 或 array table of keys 从 table 读取 nested value。
    </Card>

    <Card title="json.isArray" href="./json-isarray">
      返回 value 是否会被 Real JSON table detection treated as a JSON array。
    </Card>

    <Card title="json.isNull" href="./json-isnull">
      返回 value 是否为 Real JSON null sentinel，也就是 json.null。
    </Card>

    <Card title="json.isObject" href="./json-isobject">
      返回 value 是否会被 Real JSON table detection treated as a JSON object。
    </Card>

    <Card title="json.keys" href="./json-keys">
      返回 table 的 visible keys，放入 new table marked as a JSON array。
    </Card>

    <Card title="json.minify" href="./json-minify">
      Parse 一个 JSON string，并使用 Real default non-pretty JSON encoder output 重新 encode。
    </Card>

    <Card title="json.object" href="./json-object">
      创建 new table marked as a JSON object，让 Real JSON encoder 将其作为 object 处理。
    </Card>

    <Card title="json.parse" href="./json-parse">
      使用与 json.decode 相同的 function parse JSON string。
    </Card>

    <Card title="json.pretty" href="./json-pretty">
      使用与 json.encodePretty 相同的 function 将 Lua value serializes 为 readable formatted JSON string。
    </Card>

    <Card title="json.quote" href="./json-quote">
      使用 Real JSON string escaping rules 对 string 执行 escape，并返回 complete quoted JSON string literal。
    </Card>

    <Card title="json.stringify" href="./json-stringify">
      使用与 json.encode 相同的 function 将 Lua value serialize 为 JSON string。
    </Card>

    <Card title="json.tryDecode" href="./json-trydecode">
      使用与 json.decodeSafe 相同的 function 尝试 parse JSON string，并为 parse errors 返回 status values。
    </Card>

    <Card title="json.type" href="./json-type">
      返回值的 string type name。json.null 返回 "null"。table 使用与 json.isArray 和 json.isObject 相同的 table classification 返回 "array" 或 "object"。其他值返回 runtime Lua type name result。
    </Card>

    <Card title="json.unescape" href="./json-unescape">
      从 escaped string content 或 complete quoted JSON string literal 解码 JSON string escape sequences。输入会用 JSON string parser parse，而不是作为 full JSON document。
    </Card>

    <Card title="json.validate" href="./json-validate">
      通过 parse 一个 complete JSON value 来验证 JSON string。success 时只返回 true。parse failure 时返回 false 以及 parser error details。
    </Card>

    <Card title="json.values" href="./json-values">
      返回 table 的 direct values，放入一个 marked as JSON array 的新 table。JSON type marker entries 会被跳过。
    </Card>
  </CardGroup>
</div>
