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

> Serializes Lua value в readable formatted JSON string через Real JSON encoder. json.pretty зарегистрирован на ту же function.

<div className="real-function-page">
  ```lua theme={null}
  json.encodePretty(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.encodePretty читает те же options, что и json.encode, затем принудительно ставит 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 с pretty output forced on.

  ```lua theme={null}
  local text = json.encodePretty({
      name = "Real",
      version = 1,
      features = json.array({ "docs", "examples" }),
      missing = json.null,
  }, {
      sortKeys = true,
  })

  print(text)
  ```
</div>
