> ## 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.pretty

> json.encodePretty と同じ function を使って Lua value を readable formatted JSON string に serializes します。

<div className="real-function-page">
  ```lua theme={null}
  json.pretty(value: any, options?: EncodeOptions): string
  ```

  ## 引数

  <ParamField path={"value"} type={"any"} required>
    Encoded する value。nil、booleans、numbers、strings、tables、json.null は直接処理されます。Unsupported Lua types は errorOnUnsupported が true でない限り null として encoded されます。
  </ParamField>

  <ParamField path={"options"} type={"EncodeOptions"}>
    Optional encode options。json.pretty は json.encodePretty と同じ options を読み、その後 pretty を true に強制します。options がない場合は two-space indent を使います。number は 0.16 に clamp された indent width を設定し、string は indent text を設定し、table は sortKeys、emptyTableAsArray、errorOnUnsupported、encodeInvalidNumbersAsNull、maxDepth、indent を設定できます。
  </ParamField>

  ## 戻り値

  <ResponseField name={"json"} type={"string"}>
    Readable formatted JSON string。Encoding errors は Luau errors として throw されます。
  </ResponseField>

  ## 型

  ### EncodeOptions

  JSON のシリアル化とフォーマットを制御します。

  | Name                         | Type      | Required | 説明                                 |
  | ---------------------------- | --------- | -------- | ---------------------------------- |
  | `pretty`                     | `boolean` | No       | フォーマットされた複数行の JSON 出力を有効にします。      |
  | `sortKeys`                   | `boolean` | No       | エンコード前にオブジェクトキーをソートします。            |
  | `emptyTableAsArray`          | `boolean` | No       | 空のテーブルをオブジェクトではなく配列としてエンコードします。    |
  | `errorOnUnsupported`         | `boolean` | No       | サポートされていない値を置き換えるのではなく、エラーを発生させます。 |
  | `encodeInvalidNumbersAsNull` | `boolean` | No       | NaN と無限数を JSON null としてエンコードします。   |
  | `maxDepth`                   | `integer` | No       | ネストの最大の深さを 1 ～ 4096 の範囲で設定します。     |
  | `indent`                     | `string`  | No       | インデント文字列を設定します。32 文字に制限されます。       |

  ## 例

  json.encodePretty alias を使って JSON-compatible values を readable formatted JSON として encode します。

  ```lua theme={null}
  local text = json.pretty({
      category = "JSON",
      tags = json.array({ "pretty", "alias" }),
      missing = json.null,
  }, {
      sortKeys = true,
  })

  print(text)
  ```
</div>
