= Deserialization
\b[Deserialization] reconstructs values from a representation produced according to a format such as <JSON>. The decoder's mapping determines the resulting runtime <data types>. In <Python>, `json.loads` maps a <JSON> object to a dictionary, an array to a list, `false` to `False` and `null` to `None` by default.<Python 3.14 documentation>[json module: json.loads and JSONDecoder conversion table]{ref}
For an original example, `json.loads('{"enabled":false,"items":[null,0,"0"]}')` produces `{'enabled': False, 'items': [None, 0, '0']}`. The last two items differ: the <integer> zero and a <string data type>[string] containing a digit are not interchangeable. The decoder reconstructs nested values rather than returning the displayed source text.
Syntax and application meaning require separate checks. The malformed <JSON> `{"items":[1,2,]}` raises `JSONDecodeError`. By contrast, `{"items":"many"}` parses successfully but fails a program's requirement that `items` be a <list>. That second check is <data validation>, beyond recognizing the format's syntax.<Python 3.14 documentation>[json module: JSONDecodeError and json.loads]{ref}
Nor does successful <deserialization> guarantee recovery of every original property. A <Python> <tuple> encoded as a <JSON> array normally returns as a <list>. A round-trip claim must specify whether it preserves values, runtime types or object identity. <Character encoding> and <parsing> contribute to the reconstruction, while the selected mapping determines which distinctions survive.
Back to article page