Topic 22

Text a Program Can Read

Concept

Tessa's bookings tracker has an import button, and the note beside it says it accepts structured text. She asks the colleague who set the tracker up what that means, and he says: JSON. She braces for programming.

What she finds is labelled boxes. JSON is a strict way of writing down information so that each piece is labelled with what it is, leaving a program nothing to guess at. There is no logic in it, nothing that runs, nothing to execute — it is data wearing name tags. The letters are an abbreviation from the programming language it grew out of, and knowing that helps nobody, so treat JSON as a word in its own right. Reading it takes about ten minutes, and this page is those ten minutes.

One booking, written two ways
An ordinary sentence
The Lakeland tour, four guests, June 12th. Which words are the tour name? Is four a count or a rating? June of which year?
The same facts, labelled
One label per value: tour holds Lakeland, guests holds 4, date holds 2026-06-12. Nothing is left to interpretation, which is the entire point.

What Goes Wrong with Ordinary Sentences

Start with the problem, because the solution looks arbitrary until you have felt it. Tessa writes: the Lakeland tour, four guests, June 12th. Every human at Waymark reads that correctly and instantly.

Now be a program reading the same line. Which words are the tour name — "Lakeland", or "the Lakeland tour"? Is "four" a count of guests or a rating out of five? Is "June 12th" this year or next? The information is all there, and none of it is labelled, so the program has to work out which part is which from the way the sentence happens to be written. Write the next one slightly differently and the guessing starts over.

Think of a suitcase with a handwritten note inside saying where it should go. A person who opens it can route the bag. A luggage tag works differently: fixed fields, name and address and flight, on the outside, so any handler at any airport routes it without opening anything or reading anything they have to interpret. Labelled fields are what make handling automatic.

Reading It, Gently

Here is Tessa's booking with labels on. Read it as three pairs: a label, then the value that belongs to it.

One booking, as labelled data
{"tour": "Lakeland", "guests": 4, "date": "2026-06-12"}

Curly braces wrap one item — one booking, here — and everything inside them describes that one thing. Inside, each label sits in quotes, then a colon, then its value, and a comma separates one pair from the next. The label tour holds Lakeland, the label guests holds four, the label date holds a date written the same way every time. Nothing is left to interpretation, which is the entire point.

Values come in two flavours you will notice straight away. Text sits in quotes; numbers do not. That is not decoration — it is how the program knows that four guests is a quantity it can add up, while a tour name is a piece of text it should not try arithmetic on. There is also a plain true-or-false value, written without quotes, for fields that are answers to yes-or-no questions.

Second example: more than one booking. A list is written in square brackets, with the items inside it separated by commas.

Two bookings, as a list
[
  {"tour": "Lakeland", "guests": 4, "date": "2026-06-12"},
  {"tour": "North Shore", "guests": 2, "date": "2026-06-19"}
]

Square brackets for a list of things, curly braces for one thing, labels naming every value inside. That is the whole reading skill, and it does not get harder — a big file is this same pattern repeated two thousand times, sometimes with a set of braces tucked inside another set.

Third example, and this one is Tessa's actual work: a classified review, in the shape she will ask for on the next page.

One classified review
{"review_id": 1184, "tour": "Lakeland", "rating": 5,
 "category": "praise", "refund_mentioned": false}

Five labels, five values: which review this is, which tour it concerns, the rating as a number, which of Waymark's four buckets it went into, and whether it mentioned a refund. The buckets are the ones she defined in Chapter 4; the labels are hers too. Nobody handed her this shape — she decided what the tracker needed and wrote the labels down.

Asking the Model for It

Getting this out of the chat box is one sentence plus one example, which by now should sound familiar. "Return each review as JSON with the fields review id, tour, rating, category, and refund mentioned" — then paste one filled example, exactly as Chapter 2 taught, and the shape comes back reliably.

Models produce this format fluently, because they have read enormous amounts of it. Fluent is not the same as guaranteed, though, and the guarantee is what strictness costs you. A stray sentence of commentary before the data, a missing comma, a quote mark that never closes — and the import fails. Not partly: the tracker rejects the file and says nothing useful about why.

That cuts both ways, and the second edge is in your favour. Because the format is strict, a program can tell instantly whether a file is valid — no judgement, no reading. A machine that refuses malformed input is a machine that tells you when something went wrong, which is more than prose ever does. The page after next makes a habit of exactly that.

One practical note, so a rejected file does not become a mystery. Ask for the data and nothing else — no introduction, no closing remark, no explanation of what it did. The model's instinct is to be conversational, and a friendly opening line is the single most common reason a perfectly good file will not import.

Why This Shape Turns Up Everywhere

The reason to spend ten minutes on this is not the tracker. It is that this is how programs hand labelled information to each other across the whole internet, all day, in numbers nobody can picture. Your phone's weather, a payment going through, a flight search — labelled fields moving between machines, in this format or a close relative of it.

Which is why the tracker imports it, why half the output worth automating is worth automating because it comes in this shape, and why what Tessa learned in ten minutes is about to be worth far more than the afternoon it saved. When Chapter 7 lifts the lid on the chat box and shows the request underneath, what is inside that request is JSON — labels and values, curly braces, a list. She will recognize it on sight.

And there is a nearer payoff. A shape a program can read is a shape a program can check: ratings that must be between one and five, a category that must be one of four words, a field that must not be empty. Judgement is not required for any of that, which means it need not be Tessa's judgement doing it. Hold that thought; the last page of this chapter picks it up, and Chapter 8 finishes it.

Common Confusions
  • "JSON is programming." It is labelled data — no logic, no commands, nothing that runs. If you can read a form with the boxes filled in, you can read JSON, and you just did.
  • "The model always produces valid JSON." Usually it does, and occasionally a stray comma or a friendly opening sentence breaks it. Machines reject rather than forgive, which is why this chapter ends with checking.
  • "This is a detour from working with the model." It is the on-ramp. This is the shape of the request under every chat box, and of the output worth handing to any other piece of software.
  • "Structured output means the answer has been verified." Every value in those braces was generated, exactly like a paragraph was. Labels make text checkable; they do not make it true.
Why It Matters
  • Reading JSON is the most reusable ten minutes of technical literacy in this book — it unlocks the tracker today and makes Chapter 7's reveal feel like recognition rather than a new subject.
  • Labelled output is what lets a machine check the model's work instead of a person reading two thousand rows, which is the idea the rest of this chapter is built on.

Knowledge Check

Why is "the Lakeland tour, four guests, June 12th" a problem for a program?

  • The sentence is too long for a program to process without a lot of extra work
  • Nothing marks which part is which, so the program has to guess from the wording
  • The sentence is missing information the program needs, such as the booking reference
  • Programs cannot read ordinary written text at all, only numbers and codes

In JSON, what do square brackets mean?

  • They mark a value as text rather than as a number the program can add up
  • They surround the label that names a value, to keep it apart from the value itself
  • They hold a list of items, where curly braces would wrap a single one
  • They mark a field as optional, so a program will not complain if it is empty

The page calls JSON's strictness a trade-off. What is the trade?

  • Strict rules make the format harder for the model to produce, so answers arrive slower
  • Strict rules limit which fields you are allowed to use, so your own labels may not fit
  • Strict rules stop the model inventing values, but only for fields that hold numbers
  • One small mistake breaks the whole file, and that same rule lets a machine spot the break instantly

Where does the page say Tessa will meet this format again?

  • Inside the request that sits under the chat box, when Chapter 7 lifts the lid
  • In the guest reviews themselves, which arrive from booking sites already in this shape
  • In the 120-page supplier contract, whose clauses are stored as labelled fields
  • In the way the model reads text internally, since tokens are stored in this format

You got correct