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

> يتحقق من JSON string عن طريق parse لقيمة JSON واحدة complete. عند success يرجع true فقط. عند parse failure يرجع false مع parser error details.

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

  ## الوسائط

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

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

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

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

  <ResponseField name={"errorMessage"} type={"string | nil"}>
    Error message عند parse failure. Message تكون prefixed بـ json.validate وتتضمن near-position suffix. هذا return موجود فقط عند failure.
  </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.  |

  ## مثال

  تحقق مما إذا كان string يحتوي بالضبط على قيمة JSON واحدة complete.

  ```lua theme={null}
  print(json.validate('{"value":42}'))

  local valid, message, position = json.validate('{"value":42 trailing')

  if not valid then
      warn(message, position)
  end
  ```
</div>
