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

> Parses a JSON string with Real's JSON parser and returns the decoded Lua value, marking decoded arrays and objects for the JSON helpers.

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

  ## Arguments

  <ParamField path={"json"} type={"string"} required>
    JSON text to parse. The parser accepts one JSON value with optional surrounding whitespace and throws when invalid syntax or trailing non-whitespace characters are found.
  </ParamField>

  <ParamField path={"options"} type={"DecodeOptions"}>
    Optional decode options. A boolean sets useNull directly. A table can set useNull and maxDepth; maxDepth is clamped from 1 to 4096.
  </ParamField>

  ## Returns

  <ResponseField name={"decoded"} type={"any"}>
    Decoded value. JSON objects and arrays become tables with JSON type markers, strings become Lua strings, numbers become Lua numbers, booleans become booleans, and null becomes json.null unless useNull is false.
  </ResponseField>

  ## Types

  ### DecodeOptions

  Controls JSON parsing behavior.

  | Name       | Type      | Required | Description                                                           |
  | ---------- | --------- | -------- | --------------------------------------------------------------------- |
  | `useNull`  | `boolean` | No       | Represents JSON null with the library's null sentinel instead of nil. |
  | `maxDepth` | `integer` | No       | Sets the maximum nesting depth, clamped from 1 to 4096.               |

  ## Example

  Decode JSON into Lua values while preserving JSON array, object, and 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>
