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

> Waliduje JSON string przez parse jednej complete JSON value. Przy success zwraca tylko true. Przy parse failure zwraca false oraz parser error details.

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

  ## Argumenty

  <ParamField path={"json"} type={"string"} required>
    JSON string do validate. Function czyta ten argument przez string type checking.
  </ParamField>

  <ParamField path={"options"} type={"DecodeOptions"}>
    Optional decode options. boolean ustawia useNull. table moze ustawic useNull i maxDepth. maxDepth jest clamp od 1 do 4096.
  </ParamField>

  ## Zwroty

  <ResponseField name={"valid"} type={"boolean"}>
    true, gdy parsing jednej complete JSON value sie powiedzie. false, gdy parsing zawiedzie w protected parse block.
  </ResponseField>

  <ResponseField name={"errorMessage"} type={"string | nil"}>
    Error message przy parse failure. Message ma prefix json.validate i zawiera near-position suffix. Ten return wystepuje tylko przy failure.
  </ResponseField>

  <ResponseField name={"errorPosition"} type={"number | nil"}>
    Parser byte position z parser przy parse failure. Ten return wystepuje tylko przy failure.
  </ResponseField>

  ## Typy

  ### DecodeOptions

  Kontroluje zachowanie analizy JSON.

  | Name       | Type      | Required | Opis                                                                            |
  | ---------- | --------- | -------- | ------------------------------------------------------------------------------- |
  | `useNull`  | `boolean` | No       | Reprezentuje JSON null ze wskaźnikiem null biblioteki zamiast nil.              |
  | `maxDepth` | `integer` | No       | Ustawia maksymalną głębokość zagnieżdżenia, zaciśniętą w zakresie od 1 do 4096. |

  ## Przykład

  Sprawdza, czy string zawiera dokladnie jedna 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>
