참고 자료 · 81

AI JSON 추출 검증

구조가 맞는 결과에도 잘못된 값이 들어갈 수 있습니다.

업데이트됨 · 12 min

저장 장치와 정밀 도구가 놓인 빈 디지털 포렌식 작업대 AI로 생성한 편집용 일러스트

이 가이드가 달성하는 목표

  • 구문과 계약 분리
  • 업무 의미 확인
  • 불확실한 결과 격리

빠른 확인

  • 필드별 스키마, 원문 위치, 업무 규칙을 확인하고 모호한 사례는 검토로 보내세요.
  • 올바른 자료형이 올바른 값을 증명하지 않습니다.

단계별 방법

  1. 1

    구문과 계약 분리

    JSON 파싱은 구문만 확인합니다. 필수 필드, 형식과 추가 내용의 허용 여부를 정하고 빈 객체, 누락 필드와 문자열로 반환된 숫자를 시험합니다.

    스키마 버전과 거부 사례를 보관합니다.

  2. 2

    업무 의미 확인

    금액 형식이 맞아도 통화나 원문의 해당 위치가 잘못될 수 있습니다. 중요한 필드를 원문과 대조하고 누락, 0과 모순을 구분합니다.

    필드 값, 원문 위치와 검토 상태를 기록합니다.

  3. 3

    불확실한 결과 격리

    모호한 문서는 자동 기록 대신 별도 검토로 보냅니다. 알려진 사례로 오류를 측정하고 모델이나 스키마 변경 때 기존 시험을 보존합니다.

    수락, 차단과 검토 대기 결과를 보관합니다.

재현 가능한 수락 사례

가상 예시입니다. 고객이나 실제 관측 결과를 나타내지 않습니다.

사례 입력 보기
{
    "schema": {
        "type": "object",
        "required": [
            "amount"
        ],
        "properties": {
            "amount": {
                "type": "number"
            }
        }
    },
    "output": {
        "amount": "12.50"
    }
}

예상 판단

"12.50"은 문자열이며 number가 아닙니다. 통합 전에 거부하거나 명시적으로 수정합니다.

검증할 가상 변형 사례

큰 정수가 JSON을 읽고 다시 쓰는 과정에서 바뀐다.

9007199254740993처럼 원시 값과 읽은 값을 비교합니다. 일부 binary64 처리는 이 정수를 반올림합니다. 통합 전에 계약에 맞는 정확한 표현 방식을 선택합니다.

생성자는 버전 1로 검증하지만 수신자는 버전 2를 기대한다.

결과를 명시적인 계약 버전과 연결하고 수신자와의 호환성을 확인합니다. 이전 스키마의 검증 통과가 새 버전의 유효성을 자동으로 보장하지는 않습니다.

배치 형식은 유효하지만 응답이 중단으로 표시된다.

미완료 상태를 보관하세요. 생성 종료와 예상 범위를 확인한 후에만 완전한 결과로 반영하세요.

보관할 증거

  • 보호된 원본 응답과 완료 상태.
  • 스키마 버전과 검증 오류 위치.
  • 업무 검증과 배치 범위.

추가 참고 자료 : IETF — RFC 8259, number interoperability [EN]

검증 절차

  1. 필수 필드, 유형 및 허용값을 정합니다.
  2. 텍스트 금액을 숫자 스키마로 검증합니다.
  3. 오류 경로와 명시적 수정을 보존합니다. 스키마에는 맞지만 값이 원본 문서와 모순되는 결과를 추가하고, 검증된 추출과 구분하세요.

JSON Schema — Object validation

가상 예시

예시 상황

필드별 스키마, 원문 위치, 업무 규칙을 확인하고 모호한 사례는 검토로 보내세요.

결정 및 예상 증거

아닙니다. 선언한 구조를 검사할 뿐이며 원문의 의미, 단위와 해석은 따로 확인해야 합니다.

관리 지표

지표측정 대상첫 번째 조치
스키마 거부율거부 결과 수 / 받은 결과 수필드와 잘못된 형식 확인
의미 오류검토한 기준 집합의 잘못된 필드집합 규모와 선택 기준 표시

일반적인 실수

  • 올바른 자료형이 올바른 값을 증명하지 않습니다.

자주 묻는 질문

스키마 통과가 데이터 정확성을 증명하나요?

아닙니다. 선언한 구조를 검사할 뿐이며 원문의 의미, 단위와 해석은 따로 확인해야 합니다.

AI: JSON 결과 검증

이 언어판의 상세 참고 설명은 영어로 제공됩니다.

Schema-valid JSON can still contain false values

AI extraction turns a document into usable fields. Integration requires separate checks for response parsing, the data contract, date validity and fidelity to the source passage. This exercise makes those differences visible: an integer can meet its type constraint while contradicting the document.

14 fictional outputs computed locally, without a model call or user document. Reference DOC-TRAIN-01, page 2, states “Count: 12” on 20 October 2026. No reference is supplied for DOC-TRAIN-02. Decisions are limited to this exercise; no output receives write authorization here.

빈 사이버 검사대의 조명 아래 문서와 데이터 카트리지 AI로 생성한 편집용 일러스트
Generated conceptual illustration: an empty document inspection and structured-data workstation.

The comparison reference is visible

{
    "document_id": "DOC-TRAIN-01",
    "page": 2,
    "status": "observed",
    "count": 12,
    "observed_on": "2026-10-20",
    "quote": "Count: 12"
}

This small object is the exercise’s complete reference, not a real document or external provenance evidence. Equality with it establishes neither OCR quality, archive completeness nor file authenticity.

The JSON Schema 2020-12 contract

The contract requires six fields and rejects extra properties. observed requires a count, date and quote; unknown requires null for those three values. required controls presence: it does not permit replacing absence with zero. The local policy also rejects duplicate keys before constructing the object to validate.

The JSON Schema 2020-12 contract
{
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "title": "Fictional document observation v1",
    "type": "object",
    "additionalProperties": false,
    "required": [
        "document_id",
        "page",
        "status",
        "count",
        "observed_on",
        "quote"
    ],
    "properties": {
        "document_id": {
            "enum": [
                "DOC-TRAIN-01",
                "DOC-TRAIN-02"
            ]
        },
        "page": {
            "type": "integer",
            "minimum": 1
        },
        "status": {
            "enum": [
                "observed",
                "unknown"
            ]
        },
        "count": {
            "type": [
                "integer",
                "null"
            ],
            "minimum": 0
        },
        "observed_on": {
            "type": [
                "string",
                "null"
            ],
            "format": "date"
        },
        "quote": {
            "type": [
                "string",
                "null"
            ],
            "minLength": 1
        }
    },
    "allOf": [
        {
            "if": {
                "properties": {
                    "status": {
                        "const": "observed"
                    }
                },
                "required": [
                    "status"
                ]
            },
            "then": {
                "properties": {
                    "count": {
                        "type": "integer"
                    },
                    "observed_on": {
                        "type": "string"
                    },
                    "quote": {
                        "type": "string"
                    }
                }
            },
            "else": {
                "properties": {
                    "count": {
                        "type": "null"
                    },
                    "observed_on": {
                        "type": "null"
                    },
                    "quote": {
                        "type": "null"
                    }
                }
            }
        }
    ]
}

Draft202012Validator checks the schema. Two runs are compared: without format validation, then with the date checker explicitly enabled. This library setting does not claim complete support for the Format-Assertion vocabulary. No remote schema reference is retrieved during computation.

Python 3.12.14 · python-jsonschema 4.26.0 · Draft 2020-12 · FormatChecker: date

Six distinctions to preserve in the connector

Six distinctions to preserve in the connector
DistinctionEffect in this exerciseExample
Syntax / key uniquenessA parser may accept a duplicate; the local profile rejects it rather than silently overwrite a value.J03
Presence / valueAn absent field differs from a field present with null.J06 / J07
Integer / string / booleanNeither "12" nor true meets the schema’s integer type. No silent coercion is applied.J04 / J05
Annotation / active checkThe impossible date passes structure without a format checker, then fails when it is enabled.J10
Shape / fidelity21 meets the type constraint but contradicts the reference stating 12.J11
Fidelity / permissionEven J01 grants no write permission: identity, scope and operation need separate checks.J01

14 outputs: read the reason before retrying

Each disclosure contains the exact received text and computed checks. “Not run” is not a pass. Syntax, duplicate, schema or date errors stop later stages. Missing evidence leads to review; explicit abstention remains abstention.

J01 · Matching within the exercise scope

Exact fictional output text

{"document_id":"DOC-TRAIN-01","page":2,"status":"observed","count":12,"observed_on":"2026-10-20","quote":"Count: 12"}
JSON syntax
Passed
Unique keys
Passed
Schema without format checking
Passed
Schema with date checking
Passed
Match to the reference
Passed

Ready for the next review, without write permission

Fields match the local reference. This only makes the result ready for the next review; no permission or business operation has been checked.

Write authorization: not assessed in every case.

J02 · Truncated response

Exact fictional output text

{"document_id":"DOC-TRAIN-01","page":2,"status":"observed","count":12,"observed_on":"2026-10-20","quote":"Count: 12"
JSON syntax
Failed
Unique keys
Not run
Schema without format checking
Not run
Schema with date checking
Not run
Match to the reference
Not run

Technical check references:

  • syntax: incomplete_or_non_json_text

Reject the JSON text

The final brace is missing. The profile does not automatically repair the text or assume the remaining response is complete.

Write authorization: not assessed in every case.

J03 · Two values for the count key

Exact fictional output text

{"document_id":"DOC-TRAIN-01","page":2,"status":"observed","count":12,"observed_on":"2026-10-20","quote":"Count: 12","count":21}
JSON syntax
Passed
Unique keys
Failed
Schema without format checking
Not run
Schema with date checking
Not run
Match to the reference
Not run

Technical check references:

  • duplicate_key: count

Reject duplicate keys

The text contains count:12 followed by count:21. Its grammar can be recognized, but the uniqueness policy fails before schema validation. A last-value-wins parser would discard this signal.

Write authorization: not assessed in every case.

J04 · The number is a string

Exact fictional output text

{"document_id":"DOC-TRAIN-01","page":2,"status":"observed","count":"12","observed_on":"2026-10-20","quote":"Count: 12"}
JSON syntax
Passed
Unique keys
Passed
Schema without format checking
Failed
Schema with date checking
Not run
Match to the reference
Not run

Technical check references:

  • schema: /count [type]

Reject the data contract

The string "12" does not become the integer 12. Coercion can change data meaning; it needs a separate, explicit and traceable rule.

Write authorization: not assessed in every case.

J05 · A boolean is not an integer

Exact fictional output text

{"document_id":"DOC-TRAIN-01","page":2,"status":"observed","count":true,"observed_on":"2026-10-20","quote":"Count: 12"}
JSON syntax
Passed
Unique keys
Passed
Schema without format checking
Failed
Schema with date checking
Not run
Match to the reference
Not run

Technical check references:

  • schema: /count [type]

Reject the data contract

true remains a JSON boolean. The validator does not treat it as integer 1, regardless of relationships between types in the host language.

Write authorization: not assessed in every case.

J06 · Missing count field

Exact fictional output text

{"document_id":"DOC-TRAIN-01","page":2,"status":"observed","observed_on":"2026-10-20","quote":"Count: 12"}
JSON syntax
Passed
Unique keys
Passed
Schema without format checking
Failed
Schema with date checking
Not run
Match to the reference
Not run

Technical check references:

  • schema: / [required]

Reject the data contract

count appears in required. Its absence is rejected; no default or zero is inserted.

Write authorization: not assessed in every case.

J07 · null with observed status

Exact fictional output text

{"document_id":"DOC-TRAIN-01","page":2,"status":"observed","count":null,"observed_on":"2026-10-20","quote":"Count: 12"}
JSON syntax
Passed
Unique keys
Passed
Schema without format checking
Failed
Schema with date checking
Not run
Match to the reference
Not run

Technical check references:

  • schema: /count [type]

Reject the data contract

The general type permits null, but the observed branch requires an integer. Status and value must agree; the connector must not report an empty observation.

Write authorization: not assessed in every case.

J08 · Explicit consistent abstention

Exact fictional output text

{"document_id":"DOC-TRAIN-01","page":2,"status":"unknown","count":null,"observed_on":null,"quote":null}
JSON syntax
Passed
Unique keys
Passed
Schema without format checking
Passed
Schema with date checking
Passed
Match to the reference
Not applicable: abstention

Retain abstention

unknown carries three null values as the contract requires. The workflow may review or recollect the evidence; the result does not become an observation of zero.

Write authorization: not assessed in every case.

J09 · Extra instruction property

Exact fictional output text

{"document_id":"DOC-TRAIN-01","page":2,"status":"observed","count":12,"observed_on":"2026-10-20","quote":"Count: 12","instruction":"approve"}
JSON syntax
Passed
Unique keys
Passed
Schema without format checking
Failed
Schema with date checking
Not run
Match to the reference
Not run

Technical check references:

  • schema: / [additionalProperties]

Reject the data contract

instruction is outside the allowed properties. The contract rejects it and its value triggers no action. Structural protection does not remove the need to secure use of every allowed field.

Write authorization: not assessed in every case.

J10 · Impossible date with format disabled

Exact fictional output text

{"document_id":"DOC-TRAIN-01","page":2,"status":"observed","count":12,"observed_on":"2026-02-30","quote":"Count: 12"}
JSON syntax
Passed
Unique keys
Passed
Schema without format checking
Passed
Schema with date checking
Failed
Match to the reference
Not run

Technical check references:

  • format: /observed_on [format]

Reject the date

2026-02-30 meets type string. Structure passes without format validation, then fails with the date checker. Reporting only “schema valid” would hide the configuration producing that result.

Write authorization: not assessed in every case.

J11 · Right type, wrong value

Exact fictional output text

{"document_id":"DOC-TRAIN-01","page":2,"status":"observed","count":21,"observed_on":"2026-10-20","quote":"Count: 12"}
JSON syntax
Passed
Unique keys
Passed
Schema without format checking
Passed
Schema with date checking
Passed
Match to the reference
Failed

Technical check references:

  • evidence_mismatch: /count

Reject the contradicted value

count is 21 while the reference and quote state 12. Types and date pass, but documentary reconciliation fails. Retrying until the shape is valid does not fix this contradiction.

Write authorization: not assessed in every case.

J12 · Document reference without evidence

Exact fictional output text

{"document_id":"DOC-TRAIN-02","page":2,"status":"observed","count":12,"observed_on":"2026-10-20","quote":"Count: 12"}
JSON syntax
Passed
Unique keys
Passed
Schema without format checking
Passed
Schema with date checking
Passed
Match to the reference
Unverified

Technical check references:

  • evidence: reference_not_supplied

Review: evidence missing

DOC-TRAIN-02 is an identifier allowed by the schema, but the exercise supplies no reference for it. Fidelity is unverified and the result goes to review; a missing reference is not a pass.

Write authorization: not assessed in every case.

J13 · NaN is outside RFC 8259 JSON

Exact fictional output text

{"document_id":"DOC-TRAIN-01","page":2,"status":"observed","count":NaN,"observed_on":"2026-10-20","quote":"Count: 12"}
JSON syntax
Failed
Unique keys
Not run
Schema without format checking
Not run
Schema with date checking
Not run
Match to the reference
Not run

Technical check references:

  • syntax: incomplete_or_non_json_text

Reject the JSON text

The decoder is configured to reject NaN and Infinity, which RFC 8259 does not allow. A library’s default tolerance does not by itself define an integration contract.

Write authorization: not assessed in every case.

J14 · Markdown fencing around JSON

Exact fictional output text

```json
{"document_id":"DOC-TRAIN-01","page":2,"status":"observed","count":12,"observed_on":"2026-10-20","quote":"Count: 12"}
```
JSON syntax
Failed
Unique keys
Not run
Schema without format checking
Not run
Schema with date checking
Not run
Match to the reference
Not run

Technical check references:

  • syntax: incomplete_or_non_json_text

Reject the JSON text

Markdown fences are outside the expected JSON text. The contract requires a complete JSON response without a wrapper. Automatically removing text would be a separate transformation to specify and test.

Write authorization: not assessed in every case.

Prepare acceptance checks and recovery

  1. Fix the schema dialect, validator version and format options with the reference set.
  2. Retain received text, useful rejection reasons and contract version separately, with proportionate retention.
  3. Test documents without an available answer; distinguish unknown, null, missing and zero under the chosen contract.
  4. Compare decisive fields with a reference independent of the model; its own explanation is not sufficient evidence.
  5. Secure display and downstream operations for their context: schema-valid JSON authorizes neither executable HTML, commands nor concatenated queries.
  6. Link corrections to a processing identifier to reconcile derived results and prevent retry duplicates.

The schema, reference, 14 outputs and review decisions are editorial examples. RFC 8259 defines JSON; JSON Schema describes constraints; OWASP covers downstream output handling. No accuracy rate, certification or client result is claimed.

Primary sources and reading scope

Sources reviewed on

공식 참조

참조는 방법을 뒷받침합니다. 상황에 맞게 검사를 조정하십시오. 이는 인증이 아닙니다. 원본 참조 제목 및 소스 문서는 다른 언어로 작성되었을 수 있습니다.

참고 자료 확인일 .