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

> Parse JSON string bang Real JSON parser va tra ve decoded Lua value, danh dau decoded arrays va objects cho JSON helpers.

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

  ## Đối số

  <ParamField path={"json"} type={"string"} required>
    JSON text de parse. parser chap nhan mot JSON value voi optional surrounding whitespace va throw khi gap invalid syntax hoac trailing non-whitespace characters.
  </ParamField>

  <ParamField path={"options"} type={"DecodeOptions"}>
    Optional decode options. boolean dat useNull truc tiep. table co the dat useNull va maxDepth; maxDepth duoc clamp tu 1 den 4096.
  </ParamField>

  ## Giá trị trả về

  <ResponseField name={"decoded"} type={"any"}>
    Decoded value. JSON objects va arrays tro thanh tables voi JSON type markers, strings tro thanh Lua strings, numbers tro thanh Lua numbers, booleans tro thanh booleans, va null tro thanh json.null tru khi useNull la false.
  </ResponseField>

  ## Kiểu

  ### DecodeOptions

  Kiểm soát hành vi phân tích cú pháp JSON.

  | Name       | Type      | Required | Mô tả                                                                   |
  | ---------- | --------- | -------- | ----------------------------------------------------------------------- |
  | `useNull`  | `boolean` | No       | Biểu thị JSON null bằng giá trị null của thư viện thay vì con số không. |
  | `maxDepth` | `integer` | No       | Đặt độ sâu lồng tối đa, được kẹp từ 1 đến 4096.                         |

  ## Ví dụ

  Decode JSON thanh Lua values trong khi giu JSON array, object va 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>
