Serialization (source code)

= Serialization
{wiki}

<Serialization> maps structured program data into a representation that can be stored or transmitted, often a sequence of <bytes>. <Deserialization> reconstructs data according to that format. A useful format must specify which values and distinctions it preserves; writing an object's display text is not automatically a reversible encoding. <JSON> is one textual interchange format, with ordered <arrays> and objects whose member names are strings.<The JavaScript Object Notation (JSON) Data Interchange Format>[RFC8259, §§1–2 and4–5]{ref}

In <Python>, let `value = {"coords": [2, 5], "ready": True}`. Calling `json.dumps(value, sort_keys=True, separators=(",", ":"), allow_nan=False)` produces `{"coords":[2,5],"ready":true}`. Encoding this <string data type>[string] with <UTF-8> gives 29 <bytes>; `json.loads` reconstructs a value equal to `value`. Here <serialization> connects a nested runtime value, text and an explicit <character encoding>.<Python 3.14 documentation>[json module, Basic Usage; JSONEncoder and JSONDecoder conversion tables]{ref}

The preservation claim is deliberately specific. If `coords` originally contains the <tuple> `(2, 5)`, the default <JSON> round trip produces a list instead. Equality of the chosen first example therefore proves neither preservation of every runtime type nor preservation of object identity. Format design requires deciding which such distinctions matter.