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

> يفسر JSON string باستخدام Real JSON parser ويعيد decoded Lua value، مع تعليم decoded arrays و objects من أجل JSON helpers.

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

  ## الوسائط

  <ParamField path={"json"} type={"string"} required>
    JSON text للتفسير. يقبل parser قيمة JSON واحدة مع optional surrounding whitespace ويرمي عند invalid syntax أو trailing non-whitespace characters.
  </ParamField>

  <ParamField path={"options"} type={"DecodeOptions"}>
    Optional decode options. قيمة boolean تضبط useNull مباشرة. table يمكن أن تضبط useNull و maxDepth؛ يتم clamp لـ maxDepth من 1 إلى 4096.
  </ParamField>

  ## القيم الراجعة

  <ResponseField name={"decoded"} type={"any"}>
    Decoded value. JSON objects و arrays تصبح tables مع JSON type markers، strings تصبح Lua strings، numbers تصبح Lua numbers، booleans تصبح booleans، و null يصبح json.null إلا إذا كان useNull false.
  </ResponseField>

  ## الأنواع

  ### DecodeOptions

  يتحكم في سلوك تحليل JSON.

  | Name       | Type      | Required | الوصف                                                 |
  | ---------- | --------- | -------- | ----------------------------------------------------- |
  | `useNull`  | `boolean` | No       | يمثل JSON null مع الحارس الفارغ للمكتبة بدلاً من صفر. |
  | `maxDepth` | `integer` | No       | يضبط الحد الأقصى لعمق التعشيش، المثبت من 1 إلى 4096.  |

  ## مثال

  Decode JSON إلى Lua values مع الحفاظ على JSON array و object و 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>
