Data serialization
Data serialization converts structured values into a sequential text or binary representation for storage or transmission.
Representation: A format defines representable values; an application supplies further meaning and constraints. CBOR separates its generic data model from application-specific models and byte encodings. Successful parsing does not establish application validity. [2]
Text and bytes: JSON represents a value as text; UTF-8 is required for exchange outside a closed ecosystem. Binary formats such as CBOR specify bytes directly. Serialization is not transaction serializability, compression or encryption. [1] [2]
Round trips: Types and values survive only as far as the format and language mapping allow. Python's JSON encoder converts supported non-string dictionary keys to strings, so encoding followed by decoding need not reproduce the original dictionary. [4] Numeric precision also depends on the decoder; JSON permits implementations to limit it. [1]
Byte identity: Whitespace and string escapes can give the same JSON value different bytes. Protocol Buffers' deterministic output is not canonical across schema, build or library changes. A protocol can instead define a deterministic CBOR profile; the chosen rules still matter. [1] [3] [2]
Recovery: Preserve the representation version and required interpretation metadata. Decide whether acceptance requires original bytes, decoded values or application invariants; these are different checks. Bound input size and decoder resources for untrusted data. [2]
Relations
- related
- Concise Binary Object Representation, I-JSON, Metadata, Byte order, Data integrity, SQLite serialization, JSON Canonicalization Scheme, Variable-length integer, ZigZag encoding, Base64, Base64url, JSON text sequence, Newline-delimited JSON, Protocol Buffers, Comma-separated values (CSV), Media type, File signature
Citations
- RFC 8259: JSON grammar, numbers, strings and UTF-8 exchange, sections 2, 5, 6, 7 and 8.1
- RFC 8949: CBOR data models, deterministic encoding, validity and security, sections 2, 4.2, 5.3 and 10
- Protocol Buffers: Proto Serialization Is Not Canonical
- Python 3.12: json.dumps, supported dictionary keys and round-trip behavior
Sources & caveats
- Source synthesis with selected JSON worked examples, not a general canonicalization algorithm or a storage benchmark.
- The recovery checklist is an engineering inference from format and interpretation requirements, not a guarantee made by every serializer.