This page is the Data & JSON activity, one foundational lesson in the twelve-lesson course.
The question to explore
Build Mira’s character card
How can a program keep facts separate?
Change Mira’s age and watch one value in the record change. Giving each fact its own name lets a program find it directly. A tidy record can still hold a wrong fact. Apps and AI tools need values they can read separately. Change Mira’s age and find exactly which JSON value updates. Named fields let the next step use her age without extracting it from a paragraph; checking that age is still a separate job.
Local teaching illustration / No AI model call / About 8 minutes / No account needed
Try the experiment
First step: Find the name and age fields in the JSON record.
{
"name": "Mira",
"age": 17
}Name: Mira / Age: 17
Change a control to explore the example when JavaScript is enabled.
- Find the name and age fields in the JSON record.
- Edit Character name or choose a whole-number Age from 17 to 21. The JSON updates as you edit.
- Restore her age to 17. Explain the difference between a field name and its value.
The idea
A record gives each piece of information a name, such as name or age. JSON writes that record as text. Text values use quotes; numbers do not need them. A paragraph can show that Mira is 17. This record puts her name and age in separate named fields. That structure gives a program a specific place to look when it needs her age (record.age), rather than asking it to interpret a whole scene. A larger record could include other fields, but this activity uses only those two. JSON is a text format for structured data, defined in RFC 8259. Its values are objects, arrays, strings, numbers, true, false and null. JSON.stringify turns a JavaScript value into JSON text; JSON.parse reads the text back into a new value.
State means the values the program holds right now. Editing this record changes this activity, not the agreed facts in other lessons. Mira starts at 17. A readable record can still contain the wrong age. Quotes mark text; a number can stand on its own. The difference matters: the string "17" plus 1 gives the string "171", not 18. Parsing checks syntax only. A record can parse cleanly and still hold the wrong type or the wrong fact, which is why programs add a schema check or compare against a trusted source. The values currently held by a program are part of its state. Editing this practice record changes the experiment’s state. It does not make your new value an established fact in every other activity. The starting story still says Mira is 17.
For real data kept as separate values, the Voynich Explorer links each boxed word on a manuscript page to three transliterations, so you can read one word three ways and find where else it occurs.
Worked example: run it yourself
The script turns Mira’s record into JSON text and back, changes a copy, then shows two ways a record goes wrong: an age stored as text, and text that is not valid JSON. JSON.parse returns a new object, so changing copy.age leaves record.age at 17. An age stored as the string "17" parses without complaint, then + joins text instead of adding. Single quotes and unquoted keys are valid JavaScript but not valid JSON, so the last parse throws a SyntaxError.
Save it as record.js and run node record.js in a terminal (Node.js 18 or later), or paste it into your browser’s developer console. Download record.js
const record = { name: 'Mira', age: 17 };
const text = JSON.stringify(record);
console.log(text);
const copy = JSON.parse(text);
copy.age = 19;
console.log(record.age, copy.age);
console.log(JSON.parse('{"name":"Mira","age":17}').age + 1);
console.log(JSON.parse('{"name":"Mira","age":"17"}').age + 1);
try {
JSON.parse("{name: 'Mira'}");
} catch (error) {
console.log(error.name);
}
Output, as printed by Node.js 25.3.0 on 3 December 2026:
{"name":"Mira","age":17}
17 19
18
171
SyntaxErrorTry it
What does JSON.stringify({ name: 'Mira', age: 17, mood: undefined }) print? Predict it, then run it.
Check your answer
{"name":"Mira","age":17}. JSON has no undefined, so stringify leaves that field out without an error. Checking a record for the fields you expect catches this.
Take this with you
What changed?
Structured data gives each fact a place, but structure alone does not make a fact correct.
Try explaining it.
Could a perfectly readable JSON record give Mira the wrong age?
Open a possible explanation
Yes. Valid structure and correct story facts are separate checks. You can parse a record successfully and still need to compare it with the agreed character notes.
Choose a next step
Continue the course in order, or open the course map.