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

> Validiert einen JSON string, indem ein einzelner complete JSON value geparsed wird. Bei success gibt die Funktion nur true zurueck. Bei parse failure gibt sie false plus parser error details zurueck.

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

  ## Argumente

  <ParamField path={"json"} type={"string"} required>
    JSON string, der validated wird. Die function liest dieses argument mit string type checking.
  </ParamField>

  <ParamField path={"options"} type={"DecodeOptions"}>
    Optional decode options. Ein boolean setzt useNull. Eine table kann useNull und maxDepth setzen. maxDepth wird von 1 bis 4096 geclamped.
  </ParamField>

  ## Rückgaben

  <ResponseField name={"valid"} type={"boolean"}>
    true, wenn parsing eines einzelnen complete JSON value erfolgreich ist. false, wenn parsing im protected parse block fehlschlaegt.
  </ResponseField>

  <ResponseField name={"errorMessage"} type={"string | nil"}>
    Error message bei parse failure. Die message ist mit json.validate prefixed und enthaelt einen near-position suffix. Dieser return ist nur bei failure vorhanden.
  </ResponseField>

  <ResponseField name={"errorPosition"} type={"number | nil"}>
    Parser byte position aus dem parser bei parse failure. Dieser return ist nur bei failure vorhanden.
  </ResponseField>

  ## Typen

  ### DecodeOptions

  Steuert das JSON-Parsing-Verhalten.

  | Name       | Type      | Required | Beschreibung                                                                 |
  | ---------- | --------- | -------- | ---------------------------------------------------------------------------- |
  | `useNull`  | `boolean` | No       | Stellt JSON Null mit dem Null-Sentinel der Bibliothek anstelle von Null dar. |
  | `maxDepth` | `integer` | No       | Legt die maximale Verschachtelungstiefe fest, geklemmt von 1 bis 4096.       |

  ## Beispiel

  Prueft, ob ein string genau einen complete JSON value enthaelt.

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