liveBook · Manning

Data format

As explained in API Design Patterns

A serialization format is a defined representation for converting structured data into a transmissible or storable form and reconstructing it later.

A data format defines how structured values are represented for transmission or storage and reconstructed later. In APIs, the format becomes the shared vocabulary between servers and clients, so its types, encodings, and edge cases must be explicit. section 5.1 section 5.4.3

Use a data format deliberately:

  • Treat the format's types—not just the programming language's types—as the API contract, and document behavior for omitted or ambiguous values. section 5.1
  • Standardize string content on UTF-8 unless a strong reason requires another encoding; consider Unicode normalization when exact matching matters. section 5.4.3
  • Accept that serialization can lose information when languages provide different features, and preserve needed distinctions with explicit annotations. section 5.1

An ambiguous API value

If an API receives a + b, numeric values such as 2 and 4 suggest addition, while strings such as "2" and "4" suggest concatenation. Declaring the intended data types prevents clients and servers from guessing. section 5.1

Figure 5.1 Data moving from API server to client

Trace how formatted data moves from an API server to a client. section 5.1

How API Design Patterns covers it

How deep it goes
Explains type loss, encoding, normalization, and identifier representation, but stops short of a complete formal schema.
Examples
Uses ambiguous addition versus concatenation, UTF-8 representations of è, and Crockford’s Base32 identifiers.
What it assumes
Assumes familiarity with APIs and programming-language values while teaching serialization and cross-language type differences explicitly.
What you can do after
Apply it by choosing documented API types, standardizing encodings, and accounting for lossy or ambiguous representations.
How it connects
Connects data formats with APIs, data types, JSON, XML, YAML, UTF-8, Unicode normalization, and identifier encoding.

Also explained in

Compare how 4 books explain data format →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of API Design Patterns. The section links point to the parts of the book it draws on.