Technology

JSON Import: Identifying duplicate field names before schema validation

Technical article featuring a fictional miniature example concerning the digital exchange of cleaning schedules.

JSON Import: Identifying duplicate field names before schema validation

When exchanging digital cleaning schedules, what matters is which data a validation process actually receives. A duplicate field name can suppress information as early as the JSON file reading stage. A subsequent schema validation of the resulting object may then only see the remaining value. This technical article by Jonas Gebäudereinigung explains this difference using an explicitly fictional miniature example.

A JSON object contains named entries. The Internet standard RFC 8259 recommends that names within an object be assigned uniquely. However, repeated names do not lead to the same result in every implementation: some programs keep the last pair, others report an error, or provide all pairs. 'Readable' alone is therefore not a statement about whether all originally contained data remained intact.

The miniature example is: {"turnus":"wöchentlich","turnus":"monatlich"}. It shows two entries with the same name in the same object. This is not a complete cleaning schedule and not a data set from the Jonas schema. The freely invented field name serves only to make the mechanism visible. Both values are in the original text; which meaning should take precedence is therefore not technically decided.

The standard decoder of the Python json library keeps the last pair in such repetitions. In the own synthetic trial, 'monatlich' remained. After reversing the pair order, 'wöchentlich' remained. No client data was processed during this. The result describes this decoder with its default setting and is not a general rule for all JSON programs. The original duplicate entry cannot be restored from the simplified result alone.

This is where the limit of a subsequent schema validation begins. The data model of the JSON Schema 2020-12 specification represents an object as a set of properties in which two properties with the same name cannot be represented. The behavior for duplicate names in the source document is not defined there. If a tool checks only the resulting object, a rule cannot see the removed entry. An integrated tool can check the original text additionally; this must be clarified for the specific import path.

Python offers a starting point with object_pairs_hook to process the ordered pairs of an object during decoding. A small custom validation function was able to identify the repeated names in the synthetic trial and reject the import. This was a separate test during reading, not a validation against the Jonas schema. No finished protection function for a real client integration was proven or introduced.

The limit applies within an object. The same name may occur once in two different objects without the described repetition being present. The spelling must also be observed: A name with an escape representation can correspond to the same name after decoding as a directly written string. Simply counting visible text passages therefore does not replace a check of the decoded names in the respective object.

For those commissioning a data import, the specific question is: Are repeated names detected before a possible loss of information, and what happens then? An indication of successful schema validation only answers this question if the import path actually includes this additional control. Furthermore, the order of two entries does not decide which cleaning frequency has been agreed upon.

Jonas Gebäudereinigung already provides a public cleaning schedule data schema and a synthetic example. The article describes a general import question in this existing application context. It reports neither a new software version nor an observed Jonas error or an implemented change.

Resource: https://xn--jonas-gebudereinigung-e2b.de/ressourcen/reinigungsplan-datenschema/

Technical foundations: RFC 8259, sections 4 and 8.3; Python documentation, json; JSON Schema 2020-12, Core, section 4.2.

Sources: https://www.rfc-editor.org/info/rfc8259/ · https://docs.python.org/3/library/json.html · https://json-schema.org/draft/2020-12/json-schema-core

Corporate author: Jonas Gebäudereinigung. Created with AI assistance and checked against the stated sources; no personal human expert review claimed.

Press contact: Press assistance for Jonas Gebäudereinigung
Alexanderstraße 101 B, 26121 Oldenburg, Germany
Telephone: +49 441 24923021
Email: info@jonas-gebäudereinigung.de