İçeriğe geç

Formats, Old to New

Bu içerik henüz dilinizde mevcut değil.

Module 4 of 6 in the chapter APIs, Contracts and Data Across the Wire, chapter 3 of the Integration Architect course. Each module stands on its own. Previous: The Star Trek Transporter · Next: Schemas and Transformation

The question this module answers: Which formats does data travel in, what is each one good at, and where will you meet it?

Any communication between two systems has some form of serialization. You just need to know what it is. In the last module, the transporter turned a delivery into a stream of text. But which text? That depends on the format, and there are more of them than you’d think.

So let’s take one Steve Trucking delivery and send it through each format, from the oldest to the newest.

When I started, I read books on advanced COBOL and on JCL, the job control language. I’m dating myself. Back then, we had fixed-length formats. Every field had its own place and its own size. The first name had 20 characters. The last name had 20 characters. If the name was shorter, the rest was filled with spaces.

Here are two Steve Trucking deliveries, in a fixed-length file of our own design:

D-1042 Delivered North Corner Hardware 0412.5
D-1043 In transitSouth Hilltop Bakery 0098.0

The id takes 8 characters, the status 10, the depot 8, the recipient 20, and the weight 6. Every record is exactly the same length.

Fixed-length files were extremely fast to work with, because all you had to do was count. If every record is 53 characters, the 51st record starts at character 2,650. Just do the math, and jump straight there. But you could never change the structure later. Add one character to a field, and every position after it moves, for every system that reads the file.

And fixed-length isn’t history. It’s still alive in banking. In the United States, the files that move money between banks, ACH files, are fixed-length. In Nacha’s own words, an ACH file is “a fixed-width, ASCII file, with each line exactly 94 characters in length” (ACH File Overview (opens in a new tab), Nacha, checked 2026-11-01). If you work with banks, you may still have to write one.

Healthcare is a little different from what people often remember. The older HL7 standard, version 2, isn’t fixed-length: its fields are separated by a character, usually a pipe, like PID|1||PAT-0042||Rivera^Ana (HL7 Version 2 (opens in a new tab)). The current healthcare standard, FHIR, is REST with JSON or XML; its current published version is R5 (HL7 FHIR (opens in a new tab), checked 2026-11-01).

Then XML came along, with its tags. An open tag, the value, a close tag:

<delivery>
<id>D-1042</id>
<status>Delivered</status>
<recipient>
<name>Corner Hardware</name>
</recipient>
<items>
<item><sku>PAL-200</sku><quantity>3</quantity></item>
</items>
</delivery>

What XML gave us was room to grow. Add a new tag, and the systems that don’t know it can skip it. Fields can hold other fields, so a recipient can sit inside a delivery, and lists can repeat. Structures, like the ones in the contract, became easy to send (XML 1.0 (opens in a new tab), W3C).

For a long time, XML was the standard. SOAP is built on it. Many older systems speak it, and some industries still do. XML is getting rarer in new integrations, but it’s typically legacy, and you don’t want to change legacy around. So you’ll meet it.

Then came JSON, and today it’s the usual format for web APIs, Salesforce’s REST API among them (RFC 8259 (opens in a new tab)):

{
"id": "D-1042",
"status": "Delivered",
"recipient": { "name": "Corner Hardware" },
"items": [ { "sku": "PAL-200", "quantity": 3 } ]
}

When I ask a class why JSON won, the first answer is usually readability. That’s one. The other is size. XML can be bloated: an open tag, a close tag, the name of every field written twice. JSON writes each name once.

That mattered a lot when phones went onto 3G networks. On a slow mobile connection, every packet counted, and that’s right when JSON showed up. I used to say a JSON payload could be 30 to 40% smaller. So we measured it, with the full delivery from the contract, the same fields in each format, written compactly, the way one system sends it to another: no spaces, no line breaks.

One delivery, by size Two panels. One delivery, as sent, in bytes: XML 389, JSON 238, CSV 143 but flat, and Avro 84, in binary. Why they differ, what each one repeats: XML writes every name twice; JSON every name once; CSV the names once, in a header; Avro no names, because the schema has them. Underneath: one delivery, measured 2026-11-01; the less a format repeats, the smaller it is. {"author": "Steve Simpson", "blueprint": "1.0.1", "builder": "standard 1.57.1", "built": "2026-11-01", "id": "DGM-INT-AC-11", "rights": "\u00a9 2026 Twinshark LLC. All rights reserved.", "template": "comparison/side-by-side 0.5.0", "theme": "stevetecharc 1.4.0"} One delivery, as sent in bytes TEXT, THEN BINARY 389 XML 238 JSON 143 CSV 84 Avro Why they differ what each one repeats XML: every name, twice JSON: every name, once CSV: names once, in a header Avro: no names; the schema has them One delivery, measured 2026-11-01. The less a format repeats, the smaller it is. © 2026 Twinshark LLC · stevetecharc.com
Click to enlarge

One delivery, by size. Measured, not guessed.

The JSON was 39% smaller than the XML. That’s one payload, not a law: the gap depends on how many fields there are and how deep they go. But it’s about a third. And notice why: the less a format repeats, the smaller it is. XML writes every field’s name twice, JSON once.

The same is true of spaces. When a person reads a payload, it’s indented, one field to a line, and the spaces and line breaks count too: indented, the same delivery is 477 bytes in XML and 337 in JSON. That’s fine for reading, and it’s why systems send it compact.

JSON and XML share one weakness, and fixed-length doesn’t have it. To find the 10th record in a big JSON or XML payload, you can’t do the math. You have to read from the start, through every open and close, until you get there. With a five-megabyte payload, that takes time, and memory. Chapter 10 comes back to it.

CSV, comma-separated values, is the spreadsheet’s format: a row of column names, then one row per record (RFC 4180 (opens in a new tab)).

id,status,depot,weightKg,deliveredAt,recipientName,recipientCity
D-1042,Delivered,North,412.5,2026-11-01T14:05:00Z,Corner Hardware,Springfield

It’s the smallest of the text formats, and it’s what you’ll use to load data in bulk. Salesforce’s Bulk API 2.0 takes CSV, and only CSV, for loading data (Create a Job (opens in a new tab), Salesforce Developers, checked 2026-11-01).

But notice what’s missing. CSV is flat. The recipient had to be split into two columns. And the list of items doesn’t fit in one row at all: it needs a second file, with the delivery’s id on every row to join them back together. That’s the price of being small. Chapter 10 is bulk.

YAML carries the same structures as JSON, but it uses indentation instead of brackets and quotes, so it’s easier for people to read and write (YAML 1.2.2 (opens in a new tab)):

id: D-1042
status: Delivered
recipient:
name: Corner Hardware
items:
- sku: PAL-200
quantity: 3

You met YAML in the contract: it’s how most OpenAPI files are written. You’ll also meet it in settings files. You’ll rarely see it as the payload between two systems: it’s written for people, so it’s always indented. Even so, it’s smaller than indented JSON, 222 bytes for the same delivery, because it has no brackets and few quotes. Its one catch: the indentation is the structure. Move a line two spaces, and you’ve changed its meaning.

The last kind isn’t text at all. Binary formats pack data into bytes that only a machine can read. They’re the smallest and the fastest, and you need the schema to read them: without it, the bytes are meaningless.

You’ll meet one on Salesforce. The Pub/Sub API, the way to publish and subscribe to events at scale, carries each event’s payload in binary Apache Avro (Event Data Serialization with Apache Avro (opens in a new tab), Salesforce Developers, checked 2026-11-01; Apache Avro (opens in a new tab)). The subscriber first asks for the event’s schema, then uses it to turn the bytes back into an event.

Everything a computer stores or sends is bits, zeros and ones. Eight bits make a byte. The question is what you spend those bytes on.

A text format spends them on characters. Every letter, every digit, every bracket and quote is a character, and in UTF-8, the encoding the web uses, a basic Latin letter or digit takes one byte, an accented letter like é takes two, a character like 中 takes three, and an emoji takes four (RFC 3629 (opens in a new tab)). So the number 40, written as text, is two characters: two bytes. The delivery time, 2026-11-01T14:05:00Z, is 20 characters: 20 bytes.

A binary format doesn’t write the characters. It stores the value itself, in as few bits as it needs. In Avro, the number 40 takes one byte. The same delivery time, stored as a count of milliseconds, takes six. And the field names aren’t sent at all, because both sides have the schema (Apache Avro specification (opens in a new tab), Binary Encoding). The whole delivery came to 84 bytes, against 238 in JSON.

Text or binary Two panels, the same values as text and as binary. As text, in JSON and UTF-8: the names are in every message; the quantity 40 takes 2 bytes; the delivery time 20 bytes; the weight 412.5 5 bytes; a 2 MB photo about 2.7 MB. As binary, in Avro: no names, because the schema has them; the quantity 40 takes 1 byte; the delivery time 6 bytes; the weight 412.5 8 bytes; a 2 MB photo 2 MB. Underneath: text spends a byte or more on every character; binary stores the value itself. {"author": "Steve Simpson", "blueprint": "1.0.0", "builder": "standard 1.52.0", "built": "2026-10-28", "id": "DGM-INT-AC-12", "rights": "\u00a9 2026 Twinshark LLC. All rights reserved.", "template": "comparison/side-by-side 0.5.0", "theme": "stevetecharc 1.4.0"} As text JSON, in UTF-8 Names: in every message Quantity 40: 2 bytes Delivery time: 20 bytes Weight 412.5: 5 bytes A 2 MB photo: about 2.7 MB As binary Avro Names: none, the schema has them Quantity 40: 1 byte Delivery time: 6 bytes Weight 412.5: 8 bytes A 2 MB photo: 2 MB Text spends a byte or more on every character. Binary stores the value itself. © 2026 Twinshark LLC · stevetecharc.com
Click to enlarge

Text or binary. The same values, measured.

Not every value is smaller. The weight, 412.5, is five characters as text, and eight bytes as a binary decimal number. But across a whole message, and across millions of messages, binary wins. That’s why it still exists, and why it rules wherever volume and speed matter most: events, streams, files, the machine-to-machine traffic nobody reads.

And there’s one more reason. Put binary content into a text format, and it gets bigger. A photo of a signed delivery note is binary already. To carry it inside JSON, it has to be turned into text first, usually Base64, which writes every three bytes as four characters (RFC 4648 (opens in a new tab)). A 2 MB photo becomes about 2.7 MB of text. Send the same photo as a file, as binary, and it stays 2 MB. If you try to encode something into text, it can get really big.

Two details from Salesforce’s own documentation show why the transporter matters. The Pub/Sub API doesn’t check the payload when it’s published, so a bad payload only fails when a subscriber tries to read it. And its dates arrive as a count of time since 1970, where the older Streaming API sends them as dates in text (Differences Between Change Events Received with Streaming API vs. Pub/Sub API (opens in a new tab), checked 2026-11-01). Same event, two formats, two ways to send the time. Chapter 11 is events.

So which one? Usually, you don’t choose. The server’s contract does, and the client follows. But when you’re designing the contract yourself, every format makes a trade.

Formats, old to new Six panels, oldest first. Fixed-length, every field at its own position: fast, jump straight to any record; hard to change later; still in banking, in ACH files; today, legacy, but alive. XML, open and close tags: grows without breaking; heavier to send; SOAP, and some industries; today, still common, used less. JSON, fields, objects and lists: light and easy to read; most web APIs today; Salesforce's REST API; today, the usual choice. CSV, rows and columns: small, and flat; bulk loads; Bulk API 2.0 ingest; today, the usual choice for bulk. YAML, indented, for people: easy for people to write; specs and settings; OpenAPI files; today, the usual choice for specs. Binary, for machines, not people: smallest and fastest; needs its schema to read; Pub/Sub API events, in Avro; today, growing, for events. Underneath: every format makes a trade; the contract says which one, both ways. {"author": "Steve Simpson", "blueprint": "1.0.0", "builder": "standard 1.52.0", "built": "2026-10-28", "id": "DGM-INT-AC-10", "rights": "\u00a9 2026 Twinshark LLC. All rights reserved.", "template": "comparison/side-by-side 0.5.0", "theme": "stevetecharc 1.4.0"} Fixed-length every field at its own position Fast: jump straight to any record Hard to change later Still in banking: ACH files Today: legacy, but alive XML open and close tags Grows without breaking Heavier to send SOAP, and some industries Today: still common, used less JSON fields, objects and lists Light and easy to read Most web APIs today Salesforce's REST API Today: the usual choice CSV rows and columns Small, and flat Bulk loads Bulk API 2.0 ingest Today: the usual choice for bulk YAML indented, for people Easy for people to write Specs and settings OpenAPI files Today: the usual choice for specs Binary for machines, not people Smallest and fastest Needs its schema to read Pub/Sub API events: Avro Today: growing, for events Every format makes a trade. The contract says which one, both ways. © 2026 Twinshark LLC · stevetecharc.com
Click to enlarge

Formats, old to new. Every format makes a trade.

For a call between two systems today, JSON is the usual answer. For a large load, CSV. For events at scale on Salesforce, Avro. For a file a person will edit, YAML. For a bank, whatever the bank says. And whatever goes out, the contract should say what comes back, in the same format.

  • For every interface, the format in each direction, written in the contract.
  • For an older system, whether to speak its format, or translate it once, in one place. Module 5 is translation.
  • For bulk loads, how a structure becomes flat rows, and how the rows join back together.
  • For binary formats, where the schema lives, and who can read it.

Beyond the exam: what AI changes. AI is very good at turning one format into another: XML into JSON, a fixed-length layout into CSV, a sample payload into YAML. It’s a real time saver. But it guesses at what it can’t see: a field’s width, a date’s time zone, which rows join to which. Give it the layout, and check what it produced against the contract. Module 6 does this on a real payload.