April 28, 2026 · 5 min read
JSON for Beginners: Read Three Real Examples Line by Line
Learn JSON syntax by walking through an API response, a config file, and a broken payload you have to fix.

The fastest way to learn JSON isn't a syntax diagram, it's reading real examples until the shape becomes obvious on sight. So here are three, walked through line by line, with the gotchas flagged as they come up.
Walkthrough one: a weather API response
A typical response has an outer object holding a city name, a temperature number, and a nested object for wind data with its own speed and direction fields. The outer curly braces mark an object, a collection of key-value pairs. Keys are always wrapped in double quotes, never single quotes, never left bare. Values can be strings in quotes, numbers with no quotes, booleans written lowercase as true or false, null, another object, or an array.
Walkthrough two: a config file
Config files usually look like objects nesting simpler objects: a "theme" key holding "dark", a "maxRetries" key holding the number 3, and a "features" key holding an array of strings like ["beta", "newDashboard"]. Arrays use square brackets, and every item is separated by a comma except the last one, which must not have a trailing comma. That's the single most common mistake beginners make, since many programming languages happily allow a trailing comma and JSON simply does not.
Walkthrough three: a broken payload, fixed step by step
Here's a payload that fails to parse: unquoted keys, a trailing comma after the final array item, and a leftover comment from testing (JSON has no comment syntax at all, in any form). Fixing it means quoting every key, deleting the trailing comma, and removing the comment entirely. Running it through a JSON validator points at the exact line and character where parsing failed, which is far quicker than scanning by eye once a file gets past a few dozen lines.
The full list of types, once more
Six types exist in JSON and nothing else: string, number, boolean, null, object, and array. No date type exists (dates are almost always transmitted as ISO 8601 strings like "2026-04-28T10:00:00Z"), no undefined, no way to represent a function or a comment. That's a feature, not a gap. JSON's entire appeal is being a strict, unambiguous, language-independent format.
Places JSON shows up that surprise beginners
Beyond APIs, JSON quietly runs browser localStorage, most editor settings files, package.json in nearly every JavaScript project, and the majority of infrastructure-as-code output. Once you can read it fluently, a surprising number of "how do I configure this" problems turn into five-minute fixes instead of guesswork.
A ranked list of common mistakes
1. Trailing commas after the last item. 2. Single quotes instead of double quotes. 3. Leading zeros on numbers, like 007, which aren't valid JSON numbers at all. 4. Trying to leave an inline comment for a teammate. 5. Forgetting to escape a quote inside a string value.
Nesting depth: where beginners lose the thread
A payload three or four levels deep, an order object containing a customer object containing an addresses array containing address objects, is where most beginners lose track of which closing bracket matches which opening one. The trick: read only the indentation, ignore the content, and confirm every opening brace has a matching one at the same indent level directly below it. A code editor with bracket-matching highlighting turns this from guesswork into a two-second glance.
A quick fix, start to finish
Given a broken snippet like {name: "Alex", age: 29,}, fix it in order: wrap name in double quotes, leave age bare since numbers never take quotes, and delete the trailing comma after 29. Three small edits and the file goes from unparsable to valid.
Escaping characters inside strings
Certain characters inside a JSON string must be escaped with a backslash: a literal double quote becomes \", a backslash becomes \\\\, and a newline becomes \\n. Forgetting to escape a quote inside a string value is a common source of parse errors that looks fine to the eye but fails validation immediately, since the parser reads the unescaped quote as the end of the string.
Numbers: two real quirks
JSON numbers hide two gotchas. First, there's no distinction between integers and floats in the format itself; 3 and 3.0 are both just numbers, and it's up to whatever reads the JSON to decide how to store them. Second, very large integers can silently lose precision when parsed in JavaScript, since JavaScript represents all numbers as 64-bit floats internally. APIs dealing with large IDs often send them as strings specifically to dodge this, which is why you'll sometimes see a purely numeric ID field wrapped in quotes.
Questions worth asking
Can JSON have comments? No, never. If you need to document a config file, add a companion README or switch to a format that supports comments, like JSON5 or YAML.
Why does my JSON fail to parse even though it looks fine? The most common invisible causes are a trailing comma, a stray single quote, or an unescaped quote inside a string value. A validator points to the exact character.
Is JSON the same as a JavaScript object? They look similar, but JSON is a strict text format with rules JavaScript objects don't enforce, like requiring double-quoted keys. A JavaScript object can hold functions, and JSON cannot.
What's the difference between JSON and XML? JSON is generally more compact and easier for machines to parse, while XML supports attributes, namespaces, and comments that JSON deliberately leaves out.