serialization

Turning an in-memory object into bytes, such as JSON text, that can be sent or stored, and parsing it back again.

In more detail

Serialization mistakes, such as a missing field or a number written as a string, only show up when data really crosses a boundary, which is why integration tests matter. The reverse step, deserialization or parsing, must reject malformed input safely.

Examples

kafka-python: KafkaProducer(value_serializer=lambda v: json.dumps(v).encode())
KafkaProducer(value_serializer=lambda v: json.dumps(v).encode())
kafka-python: KafkaConsumer(value_deserializer=lambda v: json.loads(v.decode()))
In the browser: localStorage only stores strings, so objects are serialized with JSON.stringify and deserialized with JSON.parse. A resilient deserializer catches parse errors and returns a default instead of crashing.
JSON.stringify turns a query key array into a cache key string.
Go: json.Marshal to encode, json.Unmarshal to decode
Props from a Next.js Server Component to a Client Component are serialized into the RSC payload; Promises and Server Actions can cross, ordinary functions cannot.
JSON.stringify() and JSON.parse() are synchronous and block the Node.js main thread while they run.
In this course: A serializer that disagrees with the other side of a connection only shows up when real bytes cross the wire, which is why integration and contract tests exist. Common formats are JSON, Protocol Buffers and Python's own pickle.

Related terms

Taught in

References

Certification courses