> ## 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을 하나의 complete JSON value로 parse해서 검증합니다. 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>
    validate할 JSON string입니다. function은 이 argument를 string type checking으로 읽습니다.
  </ParamField>

  <ParamField path={"options"} type={"DecodeOptions"}>
    Optional decode options입니다. boolean은 useNull을 설정합니다. table은 useNull과 maxDepth를 설정할 수 있습니다. maxDepth는 1에서 4096으로 clamp됩니다.
  </ParamField>

  ## 반환값

  <ResponseField name={"valid"} type={"boolean"}>
    하나의 complete JSON value parsing이 성공하면 true입니다. protected parse block 안에서 parsing이 실패하면 false입니다.
  </ResponseField>

  <ResponseField name={"errorMessage"} type={"string | nil"}>
    parse failure일 때의 Error message입니다. message는 json.validate로 prefixed되고 near-position suffix를 포함합니다. 이 return은 failure일 때만 존재합니다.
  </ResponseField>

  <ResponseField name={"errorPosition"} type={"number | nil"}>
    parse failure일 때 parser의 Parser byte position입니다. 이 return은 failure일 때만 존재합니다.
  </ResponseField>

  ## 타입

  ### DecodeOptions

  JSON 구문 분석 동작을 제어합니다.

  | Name       | Type      | Required | 설명                                             |
  | ---------- | --------- | -------- | ---------------------------------------------- |
  | `useNull`  | `boolean` | No       | nil 대신 라이브러리의 null 센티널을 사용하여 JSON null을 나타냅니다. |
  | `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>
