Ressourcen · 81

KI-Extraktion: JSON vor der Integration prüfen

Parsing, Schema, Dokumentbelege und Fachregeln trennen, wenn Dokumente in nutzbare Datensätze überführt werden.

Aktualisiert · 8 min

Leerer digitalforensischer Arbeitsplatz mit Datenträgern und Präzisionswerkzeugen KI-generierte redaktionelle Illustration

Wozu dieser Leitfaden beiträgt

  • Ergebnisvertrag festlegen
  • Werte mit Belegen verbinden
  • In festgelegter Reihenfolge prüfen
  • Schwierige Dokumente testen
  • Wiederaufnahme und Korrektur planen

Kurzcheck

  • Kann gültiges JSON falsch sein?
  • Soll ein fehlender Wert durch 0 ersetzt werden?
  • Wann ist menschliche Prüfung nötig?

Schritt-für-Schritt-Anleitung

  1. 1

    Ergebnisvertrag festlegen

    Notieren Sie benötigte Felder, Typen, Einheiten und Zustände für fehlende Werte. JSON Schema unterscheidet beschriebene Eigenschaften und Pflichtfelder: Eine deklarierte Eigenschaft ist nicht automatisch erforderlich. Entscheiden Sie, ob weitere Felder zulässig sind. Bewahren Sie die Schemaversion je Stapel auf und sammeln Sie keine Felder ohne Zweck.

    Ergebnis: versioniertes Schema und gültige oder abgelehnte Beispiele.

  2. 2

    Werte mit Belegen verbinden

    Verlangen Sie Seiten-, Textstellen- oder Zellreferenzen für Werte, die eine Aktion auslösen. Erlauben Sie einen unbekannten Zustand bei fehlenden Angaben. Ein korrekt typisierter Betrag kann zu einem anderen Dokument gehören; ein plausibles Datum kann das Ausstellungsdatum statt der Fälligkeit sein.

    Ergebnis: Zuordnung von Feld, Beleg und Leseregel.

  3. 3

    In festgelegter Reihenfolge prüfen

    Prüfen Sie JSON-Parsing, Schema und anschließend Fachregeln wie zulässige Währung, vorhandene Kennung, Zeilensummen und zeitliche Reihenfolge. Schemakonformität beweist weder sachliche Richtigkeit noch Schreibberechtigung. Fachliche Aktionen bleiben gesperrt, bis ihre Bedingungen erfüllt sind.

    Ergebnis: getrennte Fehlerklassen und Annahmeentscheidungen.

  4. 4

    Schwierige Dokumente testen

    Berücksichtigen Sie getrennte Tabellen, mehrere Sprachen, widersprüchliche Werte, leere Dokumente und feindliche Anweisungen im Quelltext. Testen Sie Ablehnungen, abgeschnittene Antworten und Wiederholungen. Halten Sie Prüfbeispiele von der Optimierung getrennt und betrachten Sie Fehler je Feld statt eine Gesamtrate als Garantie zu verwenden.

    Ergebnis: Referenzsatz und Liste kritischer Fehler.

  5. 5

    Wiederaufnahme und Korrektur planen

    Verknüpfen Sie Dokument, Modellversion, Schema und Ergebnis mit einer Verarbeitungskennung. Eine Wiederholung darf keine zwei Datensätze erzeugen. Bewahren Sie Gründe menschlicher Korrekturen auf und finden Sie abgeleitete Ausgaben. Kopieren Sie vollständige Dokumente nicht unnötig in Protokolle.

    Ergebnis: Verfahren für Korrektur und kontrollierte Wiederholung.

Von lesbaren Ergebnissen zur berechtigten Aktion

Eine bestandene Prüfung ersetzt die nächste nicht. Stoppen Sie bei einer nicht erfüllten notwendigen Bedingung.

  1. JSON parsen

    Ist die Antwort vollständig und lesbar?

  2. Vertrag prüfen

    Passen Typen, Felder, Einheiten und fehlende Werte zum Schema?

  3. Werte prüfen

    Belegen Quellen und Fachregeln die Werte?

  4. Aktion berechtigen

    Sind Identität, Umfang und Schreibbedingungen erfüllt?

Fiktives Beispiel: Parsing und Schema stimmen, aber zwei Beträge widersprechen sich. Schreiben bleibt gesperrt und der Datensatz wird geprüft.

Nachvollziehbarer Abnahmefall

Fiktives Beispiel: Diese Daten beschreiben keine Kunden oder beobachteten Ergebnisse.

Falldaten anzeigen
{
    "schema": {
        "type": "object",
        "required": [
            "amount"
        ],
        "properties": {
            "amount": {
                "type": "number"
            }
        }
    },
    "output": {
        "amount": "12.50"
    }
}

Erwartete Entscheidung

"12.50" ist Text, kein number. Vor Integration ablehnen oder ausdrücklich korrigieren.

Fiktive Varianten zum Prüfen

Eine große Ganzzahl ändert sich beim Lesen und erneuten Schreiben von JSON.

Vergleichen Sie Rohwert und eingelesenen Wert, etwa 9007199254740993. Manche Binary64-Verarbeitungen runden diese Ganzzahl. Wählen Sie vor der Integration eine zum Vertrag passende exakte Darstellung.

Der Erzeuger prüft mit Version 1, der Empfänger erwartet jedoch Version 2.

Ordnen Sie das Ergebnis einer ausdrücklichen Vertragsversion zu und prüfen Sie die Kompatibilität mit dem Empfänger. Eine erfolgreiche Prüfung mit einem älteren Schema bestätigt nicht automatisch die neue Version.

Der Stapel ist gültig, die Antwort aber als unterbrochen markiert.

Behalten Sie den unvollständigen Status bei. Prüfen Sie Generierungsende und erwartete Abdeckung vor der Übernahme als vollständiges Ergebnis.

Zu sichernde Nachweise

  • Geschützte Rohantwort und Abschlussstatus.
  • Schemaversion und verortete Validierungsfehler.
  • Fachliche Prüfungen und Abdeckung des Stapels.

Ergänzende Referenz : IETF — RFC 8259, number interoperability [EN]

Prüfverfahren

  1. Pflichtfelder, Typen und erlaubte Werte festlegen.
  2. Textbetrag gegen Zahlenschema validieren.
  3. Fehlerpfad und ausdrückliche Korrektur aufbewahren. Ergänzen Sie ein schemakonformes Ergebnis mit einem Wert, der dem Quelldokument widerspricht; trennen Sie es von einer verifizierten Extraktion.

JSON Schema — Object validation

Wiederverwendbares Arbeitsblatt

Ergänzen Sie Ihre autorisierten Beobachtungen. Bei diesen Feldern handelt es sich um eine Arbeitsvorlage, nicht um beobachtete Ergebnisse.

FeldZu erfassende Informationen
VertragFelder, Typen, Einheiten, fehlende Werte und Schemaversion
BelegDokument und Textstelle für jedes entscheidende Feld
PrüfungParsing, Schema, Fachregeln und Ablehnungsgrund
WiederaufnahmeVerarbeitungskennung, vermiedene Duplikate und übernommene Korrekturen

Fiktives Arbeitsbeispiel

Beispielhafte Situation

Fiktives Beispiel: Ein Extraktor findet zwei Rechnungssummen und wählt den Nettobetrag, obwohl die Integration den Zahlbetrag erwartet.

Entscheidung und erwartete Beweise

Das Schema akzeptiert die Zahl, aber der Abgleich von Zeilen und Währung verhindert den Schreibvorgang und leitet das Dokument zur Prüfung weiter.

Unterscheiden Sie die Mechanismen

MechanismusZweckÜberprüfung oder Einschränkung
Lesbares JSONParsing ermöglichenPrüft weder erwartete Felder noch Bedeutung
SchemakonformitätTypen und Einschränkungen prüfenBeweist keine Quellentreue
Fachlicher AbgleichNutzbarkeit und Konsistenz prüfenBenötigt eindeutige Regeln und Referenzen

Managementindikatoren

IndikatorWas es misstErste Aktion
FeldgenauigkeitKorrekte Werte unter den prüfbaren FeldernFehler mit Einfluss auf Aktionen priorisieren
Sinnvolle EnthaltungUnentschiedene Fälle ohne BelegWarteschlange prüfen, ohne erfundene Werte zu fördern
Duplikate bei WiederholungMehrfache Datensätze derselben VerarbeitungDeduplizierung korrigieren

Häufige Fallstricke

  • Prüft weder erwartete Felder noch Bedeutung
  • Beweist keine Quellentreue
  • Benötigt eindeutige Regeln und Referenzen

Häufig gestellte Fragen

Kann gültiges JSON falsch sein?

Ja. Syntax und Schema können stimmen, obwohl Betrag, Identität oder Datum falsch sind. Prüfen Sie entscheidende Werte anhand ihrer Quellen.

Soll ein fehlender Wert durch 0 ersetzt werden?

Verwenden Sie nur die im Vertrag festgelegte Bedeutung. Ein fehlender Wert, null und die Zahl 0 sind unterschiedliche Zustände; erfundene Vorgaben verfälschen Berechnungen.

Wann ist menschliche Prüfung nötig?

Wenn Widersprüche, fehlende Belege oder kritische Fehler außerhalb des akzeptierten Umfangs liegen. Definieren Sie diese Fälle vor der Stapelverarbeitung.

KI: JSON-Ergebnisse prüfen

Ausführliche Hinweise stehen in dieser Ausgabe auf Englisch zur Verfügung.

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.

Beleuchtetes Dokument und Datenkassetten an einer leeren Cyberprüfstation KI-generierte redaktionelle Illustration
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

Offizielle Referenzen

Die Referenzen unterstützen die Methode. Passen Sie die Prüfungen an Ihren Kontext an; sie stellen keine Zertifizierung dar. Originalreferenztitel und Quelldokumente können in einer anderen Sprache verfasst sein.

Referenzen geprüft am .