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

> Serializa un Lua value a un readable formatted JSON string usando la misma function que json.encodePretty.

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

  ## Argumentos

  <ParamField path={"value"} type={"any"} required>
    Value que se encoded. nil, booleans, numbers, strings, tables y json.null se manejan directamente. Unsupported Lua types se encoded como null salvo que errorOnUnsupported sea true.
  </ParamField>

  <ParamField path={"options"} type={"EncodeOptions"}>
    Optional encode options. json.pretty lee las mismas options que json.encodePretty y luego fuerza pretty a true. Sin options usa un two-space indent. Un number define la indent width con clamp a 0.16, un string define el indent text, y una table puede definir sortKeys, emptyTableAsArray, errorOnUnsupported, encodeInvalidNumbersAsNull, maxDepth e indent.
  </ParamField>

  ## Retornos

  <ResponseField name={"json"} type={"string"}>
    Readable formatted JSON string. Encoding errors se lanzan como Luau errors.
  </ResponseField>

  ## Tipos

  ### EncodeOptions

  Controla la serialización y el formato JSON.

  | Name                         | Type      | Required | Descripción                                                         |
  | ---------------------------- | --------- | -------- | ------------------------------------------------------------------- |
  | `pretty`                     | `boolean` | No       | Habilita la salida JSON formateada y de varias líneas.              |
  | `sortKeys`                   | `boolean` | No       | Ordena las claves de los objetos antes de codificar.                |
  | `emptyTableAsArray`          | `boolean` | No       | Codifica una tabla vacía como una matriz en lugar de un objeto.     |
  | `errorOnUnsupported`         | `boolean` | No       | Genera un error en lugar de sustituir valores no admitidos.         |
  | `encodeInvalidNumbersAsNull` | `boolean` | No       | Codifica NaN y números infinitos como JSON nulo.                    |
  | `maxDepth`                   | `integer` | No       | Establece la profundidad máxima de anidamiento, sujeta de 1 a 4096. |
  | `indent`                     | `string`  | No       | Establece la cadena de sangría, limitada a 32 caracteres.           |

  ## Ejemplo

  Encode JSON-compatible values como readable formatted JSON usando el 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>
