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

> Serializes Lua value в readable formatted JSON string через ту же function, что json.encodePretty.

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

  ## Аргументы

  <ParamField path={"value"} type={"any"} required>
    Value для encoded. nil, booleans, numbers, strings, tables и json.null обрабатываются напрямую. Unsupported Lua types encoded как null, если errorOnUnsupported не true.
  </ParamField>

  <ParamField path={"options"} type={"EncodeOptions"}>
    Optional encode options. json.pretty читает те же options, что json.encodePretty, затем принудительно ставит pretty в true. Без options используется two-space indent. number задает indent width с clamp до 0.16, string задает indent text, а table может задавать sortKeys, emptyTableAsArray, errorOnUnsupported, encodeInvalidNumbersAsNull, maxDepth и indent.
  </ParamField>

  ## Возвраты

  <ResponseField name={"json"} type={"string"}>
    Readable formatted JSON string. Encoding errors выбрасываются как Luau errors.
  </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 символами.     |

  ## Пример

  Encode JSON-compatible values как readable formatted JSON через json.encodePretty alias.

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

  print(text)
  ```
</div>
