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

> Parsea un JSON string con Real JSON parser y devuelve el decoded Lua value, marcando decoded arrays y objects para los JSON helpers.

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

  ## Argumentos

  <ParamField path={"json"} type={"string"} required>
    JSON text para parsear. El parser acepta un JSON value con optional surrounding whitespace y lanza error con invalid syntax o trailing non-whitespace characters.
  </ParamField>

  <ParamField path={"options"} type={"DecodeOptions"}>
    Optional decode options. Un boolean establece useNull directamente. Una table puede establecer useNull y maxDepth; maxDepth se clampa de 1 a 4096.
  </ParamField>

  ## Retornos

  <ResponseField name={"decoded"} type={"any"}>
    Decoded value. JSON objects y arrays se vuelven tables con JSON type markers, strings se vuelven Lua strings, numbers se vuelven Lua numbers, booleans se vuelven booleans, y null se vuelve json.null salvo que useNull sea false.
  </ResponseField>

  ## Tipos

  ### DecodeOptions

  Controla el comportamiento de análisis de JSON.

  | Name       | Type      | Required | Descripción                                                                   |
  | ---------- | --------- | -------- | ----------------------------------------------------------------------------- |
  | `useNull`  | `boolean` | No       | Representa JSON nulo con el centinela nulo de la biblioteca en lugar de nulo. |
  | `maxDepth` | `integer` | No       | Establece la profundidad máxima de anidamiento, sujeta de 1 a 4096.           |

  ## Ejemplo

  Decode JSON a Lua values preservando JSON array, object y null markers.

  ```lua theme={null}
  local value = json.decode('{"name":"Real","tags":["docs"],"missing":null}')

  print(value.name)
  print(value.tags[1])
  print(json.type(value))
  print(json.isNull(value.missing))
  ```
</div>
