Articles/Phase 2 — HTTP & Data Wire Protocols

Serialization and Deserialization for Backend Engineers

Language-agnostic wire communication, OSI application layer boundaries, JSON structure rules, and text vs binary serialization formats.

Core Concept & First Principle

Serialization converts in-memory objects into a standard wire format (like JSON or Protobuf) for network transmission; Deserialization reconstructs wire bytes back into native objects. This common standard allows frontend apps in JavaScript and backends in Rust, Go, or Python to communicate seamlessly.

1. The Core Problem: Heterogeneous Languages Across Networks

In modern software architecture, client and server applications are almost always written in completely different programming languages. A frontend client running JavaScript in Google Chrome might communicate with a backend microservice written in Rust, Go, Python, or Java.

Because JavaScript objects and Rust typed structs have completely different memory layouts, machines cannot simply pass raw internal memory pointers across a network wire. They need a shared, language-agnostic common standard.

The First-Principles Solution
Both the client and server agree on a universal standard data format (like JSON). The client transforms its local data into this format before sending, and the server converts it into its own native types upon arrival.

2. What is Serialization & Deserialization?

1Serialization (Encoding / Marshalling)

The process of taking an active in-memory data structure (an object, struct, or dictionary) and converting it into a standardized string or binary byte stream suitable for network transmission or disk storage.

2Deserialization (Decoding / Unmarshalling)

The reverse process of taking raw received wire bytes or text and parsing them back into native in-memory data types so backend business logic and database queries can safely run.
Example: JavaScript Client to Rust Backend Transformation
INPUT / REQUEST
// Client: JavaScript Object in Browser Memory
const newBook = { title: "Designing Data-Intensive Applications", author: "Martin Kleppmann" };
// Serialized into wire string:
JSON.stringify(newBook);
// ➔ '{"title":"Designing Data-Intensive Applications","author":"Martin Kleppmann"}'
OUTPUT / RESULT
// Server: Deserialized into Rust Struct in Server Memory
#[derive(Deserialize, Serialize)]
struct BookDto {
    title: String,
    author: String,
}
// let book: BookDto = serde_json::from_str(&wire_payload)?;
Takeaway:Even though JavaScript and Rust share no runtime or memory model, both seamlessly understand the intermediate JSON wire format.

3. The Backend Mental Model & The OSI Layer Boundary

The Open Systems Interconnection (OSI) model describes network communication across 7 distinct layers, from the Application Layer (Layer 7) down to the Physical hardware layer (Layer 1).

As network packets travel across the internet, operating systems and routers convert application data into data frames, IP packets, and raw electrical/optical bits (010101). However, as a backend engineer, you operate at the Application Layer.

The Golden Mental Model for Backend Engineers
You do not need to manage intermediary packet slicing or physical voltage bits. You serialize data into JSON at the Application Layer; the network stack transmits it, and the receiving server reconstructs the exact same JSON format before passing it to your controller.

4. Serialization Standards: Text-Based vs. Binary Formats

Serialization standards generally fall into two primary architectural categories: text-based formats and binary formats:

Comparison Table↔ Scroll horizontally
FormatCategoryPrimary Use Case & Characteristics
JSONText-BasedUniversal standard (~80% of Web & REST APIs). Completely human-readable, lightweight, and native to all major languages.
YAMLText-BasedHuman-friendly configuration files (Kubernetes manifests, Docker Compose, CI/CD pipelines).
XMLText-BasedTag-heavy legacy enterprise format (SOAP web services, banking mainframes). Highly verbose.
Protocol Buffers (Protobuf)Binary FormatHigh-performance binary serialization used with gRPC for low-latency internal microservices. ~40-60% smaller than JSON.
MessagePack / AvroBinary FormatCompact schema-driven binary encoding for fast event streaming and analytics pipelines.

5. JSON Structure & Syntax Rules

JSON (JavaScript Object Notation) is the most widely used serialization format for HTTP REST APIs. It is strictly governed by fundamental syntax rules:

1Enclosing Braces

Objects must begin with an opening brace { and end with a matching closing brace }.

2Keys Must Be Quoted Strings

Every object key MUST be wrapped in double quotes ("name": "Sachin"). Single quotes or unquoted keys are invalid JSON.

3Supported Value Types

Values can be Strings, Numbers (integers or floats), Booleans (true/false), Arrays ([...]), Nested Objects ({...}), or null.
1// Deserialization: JSON wire string ➔ JavaScript Object
2const book = JSON.parse(rawWireText);
3
4// Serialization: JavaScript Object ➔ JSON wire string
5const wireText = JSON.stringify({ id: 101, title: 'Designing Data-Intensive Applications' });
6res.setHeader('Content-Type', 'application/json');
7res.send(wireText);

6. End-to-End Request & Response Serialization Flow

Here is the complete lifecycle of a client-server interaction from first principles:

Example: Full Wire Serialization Cycle
INPUT / REQUEST
// 1. CLIENT SENDS REQUEST (Serialized JSON Body)
POST /api/books HTTP/1.1
Host: api.example.com
Content-Type: application/json

{
  "id": 6,
  "title": "Database Internals",
  "author": "Alex Petrov"
}
OUTPUT / RESULT
// 2. SERVER RESPONDS (Serialized JSON Response Array)
HTTP/1.1 201 Created
Content-Type: application/json

{
  "status": "success",
  "data": [
    { "id": 1, "title": "Designing Data-Intensive Applications" },
    { "id": 6, "title": "Database Internals" }
  ]
}
Takeaway:Client serializes an input object into JSON text. Server deserializes it into SQL records, writes to disk, serializes the updated list into a response JSON array, and client deserializes the response to render the UI.
Summary & Core Takeaways
Key Insights
1Serialization converts in-memory objects into standardized wire formats (JSON, Protobuf) for network transmission or disk storage.
2Deserialization reconstructs wire bytes back into native in-memory objects so business logic can run safely.
3JSON is the universal (~80%) text standard for REST APIs because it is human-readable and language-agnostic.
4As a backend engineer, you operate at the Application Layer (Layer 7)—you define schemas and contracts while network hardware handles packet transmission.
5For high-speed internal microservices, binary serialization formats like Protocol Buffers reduce payload sizes by up to 50% compared to JSON.
API Sandbox (2 Live Endpoints)
Serialization
Live API

17. JSON Wire Serialization & Parsing

Sends a structured JSON payload, inspects server-side deserialization into memory, and observes re-serialized JSON response.

Headers:Content-Type: application/json
Request Body (JSON Payload)Valid JSON
Serialization
Live API

18. Format Comparison: JSON vs YAML vs XML vs Protobuf

Compares text-based formats (JSON, YAML, XML) with binary wire formats (Protobuf) showing byte compactness and parsing differences.

Headers:Content-Type: application/json
Request Body (JSON Payload)Valid JSON