Data format interoperability (source code)

= Data format interoperability

\b[Data format interoperability] means that independent producers and consumers can exchange data with an agreed interpretation. Sharing a syntax is one part of that agreement; <character encoding>, supported values and handling of ambiguous inputs also matter. <Serialization> and <deserialization> must preserve the distinctions the application needs.<The JavaScript Object Notation (JSON) Data Interchange Format>[RFC8259, §1.3 interoperability motivation; §§4,6 and8.1]{ref}

Consider the original <JSON> input `{"mode":"fast","mode":"safe"}`. RFC8259 says object member names should be unique and warns that duplicate-name handling differs. In <Python>, the default `json.loads` result is `{'mode': 'safe'}`. The same decoder with `object_pairs_hook=list` instead returns `[('mode', 'fast'), ('mode', 'safe')]`, preserving both pairs.<The JavaScript Object Notation (JSON) Data Interchange Format>[§4: object names and duplicate-name interoperability]{ref}<Python 3.14 documentation>[json module: Repeated Names Within an Object; object_pairs_hook]{ref}

The text has not changed, yet one consumer retains one value and another retains both occurrences. Re-encoding the default dictionary cannot recover the discarded occurrence. A consumer can instead use a hook that rejects a repeated name, making the ambiguity explicit before the application acts on it.

An exchange contract can therefore require unique names and a shared duplicate-rejection policy, as well as a <character encoding> such as <UTF-8>. That is a stronger agreement than merely saying that both programs support <JSON>. <Data validation> then checks application-level requirements on the agreed decoded representation.