Data formats cheatsheet
Writing and Understanding JSON
Read objects and arrays, choose the right value types, and spot the punctuation mistakes that break JSON.
JSON stores structured information as text. Use it for records, settings, and data exchanged between tools.
Start with an example
{
"project": "Community garden",
"active": true,
"volunteers": 12,
"tasks": ["Plant seeds", "Water beds"],
"location": {
"city": "Madison",
"room": null
}
}
Read this from the outside in: one object describes a project. The tasks array holds two items. The nested location object groups related details.
The building blocks
| Mark or value | Meaning | Example |
|---|---|---|
{ } |
Object: named properties | {"city": "Madison"} |
[ ] |
Array: ordered items | ["Plant", "Water"] |
: |
Separates a property name from its value | "volunteers": 12 |
, |
Separates properties or array items | [1, 2, 3] |
| String | Text in double quotes | "Community garden" |
| Number | A numeric value without quotes | 12, -3, 1.5 |
| Boolean | A true-or-false value | true, false |
| Null | An explicit null value | null |
Property names must be strings. Arrays preserve order; do not rely on an object’s property order. An entire JSON document can also be a single value, such as 42 or true. JSON syntax reference.
Write valid JSON
- Use straight double quotes:
"name", not single or curly quotes. - Put commas between items. Leave no comma after the last item.
- Write
true,false, andnullin lowercase, without quotes. - Keep comments outside the JSON. Standard JSON has no comment syntax.
- Match every opening brace or bracket with its closing partner.
- Give each property a unique name within its object; duplicate names can produce inconsistent results across tools.
These rules follow RFC 8259.
Keep the meaning straight
12 is a number; "12" is text. false is a boolean; "false" is text. null, "", and an omitted property can mean different things to the receiving tool.
Use strings for identifiers such as "00123" when leading zeros matter. JSON has no date type; agree on a string format with the receiving tool, such as "2026-09-13".
Inside strings, escape quotation marks and backslashes:
{
"message": "She said \"ready\".",
"path": "C:\\notes\\garden.json",
"two_lines": "Plant seeds\nWater beds"
}
The \n represents a line break inside the text. It is not a literal line break in the JSON source. String and number rules.
When it will not parse
- Start at the reported line, then inspect the line before it.
- Check quotes, commas, and matching brackets.
- Format the document in your editor to make its nesting visible.
- Confirm that the receiving tool expects this structure. Valid JSON can still contain the wrong fields or value types.
Keep one small working example beside the file you are editing. Add one property at a time while learning.