> ## 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 одного complete JSON value. При 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 одного complete JSON value успешен. false, если parsing не проходит внутри protected parse block.
  </ResponseField>

  <ResponseField name={"errorMessage"} type={"string | nil"}>
    Error message при parse failure. Message имеет prefix 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 с нулевым контрольным значением библиотеки вместо nil. |
  | `maxDepth` | `integer` | No       | Устанавливает максимальную глубину вложенности от 1 до 4096.                           |

  ## Пример

  Проверяет, содержит ли string ровно один complete JSON value.

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