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

> يحاول parse لـ JSON string باستخدام نفس function مثل json.decodeSafe ويرجع status values لـ parse errors.

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

  ## الوسائط

  <ParamField path={"json"} type={"string"} required>
    JSON string يتم parse له. Function تقرأ هذا argument باستخدام string type checking.
  </ParamField>

  <ParamField path={"options"} type={"DecodeOptions"}>
    Optional decode options. boolean يضبط useNull. table يمكنها ضبط useNull و maxDepth.
  </ParamField>

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

  <ResponseField name={"success"} type={"boolean"}>
    true عندما ينجح parsing، و false عندما يفشل parsing داخل protected parse block.
  </ResponseField>

  <ResponseField name={"decoded"} type={"any | nil"}>
    Decoded value عند success. عند parse failure، هذا return يكون nil.
  </ResponseField>

  <ResponseField name={"errorMessage"} type={"string | nil"}>
    Error message عند parse failure. Message تكون prefixed بـ json.decodeSafe وتتضمن near-position suffix.
  </ResponseField>

  <ResponseField name={"errorPosition"} type={"number | nil"}>
    Parser byte position من parser عند parse failure. هذا return موجود فقط عند failure.
  </ResponseField>

  ## الأنواع

  ### DecodeOptions

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

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

  ## مثال

  Decode JSON مع status returns باستخدام json.decodeSafe-compatible alias.

  ```lua theme={null}
  local ok, value, message, position = json.tryDecode('{"ready":true,"missing":null}', {
      useNull = true,
  })

  if ok then
      print(value.ready)
      print(json.isNull(value.missing))
  else
      warn(message, position)
  end
  ```
</div>
