# JSON: what the format is, syntax rules, examples and common errors

Source: https://checkcraft.ru/en/guides/json-format-guide.html · updated 2026-11-24

What JSON is in plain words: its building blocks, six value types, syntax rules, an example with objects and arrays.

Practical workflow

Checkcraft is a desktop app for checking APIs and logs without code, with a free edition. [Download, no sign-up →](https://checkcraft.ru/en/download-checkcraft.html#free-download)

JSON is a text format for exchanging data between programs. Every programming language reads it, so most APIs answer in it, settings are stored in it and logs are written in it. The format is simple: objects in curly braces, arrays in square brackets and six value types. Below are the rules, an example and the errors people hit most.

Checkcraft · 24 November 2026

Get help with your first test →

## What JSON consists of

An object is a set of key: value pairs in curly braces; the key is always a string in double quotes. An array is an ordered list of values in square brackets. A value is a string, a number, true or false, null, another object or an array. Nesting is unlimited, which suits an order with items or a customer with addresses.

## What JSON does not have

JSON has no comments, single quotes, unquoted keys or trailing commas. There is no date type: dates travel as strings, usually ISO 8601. Integers and decimals are not distinguished, and NaN and Infinity are forbidden. All of this is allowed in a JavaScript object, which causes most errors.

Checked one response? Save the rule in Checkcraft and it works on every next one. [Download Free →](https://checkcraft.ru/en/download-checkcraft.html#free-download)

## Valid JSON is not yet a correct response

A syntax check only says the text can be parsed. It will not tell you the total is wrong, the status is not in the list or an internal field leaked. That takes content checks: a schema, field rules and calculations.

## A JSON example

```
{
  "id": 5001,
  "status": "PAID",
  "createdAt": "2026-11-09T10:15:00Z",
  "customer": { "id": 7, "name": "Анна Петрова", "phone": null },
  "items": [
    { "productId": 101, "name": "Мышь", "quantity": 2, "price": 1290.0 },
    { "productId": 102, "name": "Кабель", "quantity": 1, "price": 590.0 }
  ],
  "subtotal": 3170.0,
  "discount": 300.0,
  "total": 2870.0,
  "gift": false
}
```

This is an order object: numbers have no quotes, strings use double quotes, a missing phone is null, and items are an array of objects. Indentation and line breaks are optional and only help people.

## Value types

| Type | Example | Watch out for |
|---|---|---|
| String | "PAID" | Double quotes only; escape quotes and backslashes: \" and \\ |
| Number | 42, -3.14, 1e6 | No quotes or leading zeros; NaN and Infinity are forbidden |
| Boolean | true, false | Lowercase only |
| Null | null | Not the same as an empty string or a missing field |
| Object | {"id": 7} | Keys are double-quoted strings |
| Array | [1, 2, 3] | Order matters, types may differ |

## JSON, JavaScript object, XML and YAML

|  | JSON | JavaScript object | XML | YAML |
|---|---|---|---|---|
| Comments | No | Yes | Yes | Yes |
| Quoted keys | Required, double | Optional | Tags instead of keys | Optional |
| Trailing comma | Error | Allowed | n/a | n/a |
| Data types | Six types | Plus functions, dates, undefined | All text, schema sets types | Like JSON plus dates |
| Where used | APIs, logs, settings | Code | SOAP, documents | Settings, CI |

## Common JSON errors

| Error | What it looks like | More |
|---|---|---|
| Trailing comma | {"a": 1,} | [Unexpected token](https://checkcraft.ru/en/guides/json-unexpected-token.html) |
| Single quotes or unquoted key | {'a': 1} or {a: 1} | [Unexpected token](https://checkcraft.ru/en/guides/json-unexpected-token.html) |
| An HTML page instead of JSON | <!DOCTYPE html>… | [DOCTYPE is not valid JSON](https://checkcraft.ru/en/guides/json-doctype-not-valid.html) |
| Truncated or empty response | {"items": [ | [Unexpected end of JSON input](https://checkcraft.ru/en/guides/json-unexpected-end.html) |
| Generic parse failure | JSON parse error | [JSON parse error](https://checkcraft.ru/en/guides/json-parse-error.html) |
| A long number lost precision | 12345678901234567890 → …67000 | [JSON formatter](https://checkcraft.ru/en/guides/json-formatter-online.html) |

## What happens when a key repeats

The JSON standard does not forbid repeating a key in one object, so every library chooses which value to keep. On 25 November 2026 we ran one response through five parsers:

```
{"orderId":5002,"status":"PAID","amount":2970,"status":"CANCELLED"}
```
| Parser | Result |
|---|---|
| Python, json.loads | status = CANCELLED |
| Node.js, JSON.parse | status = CANCELLED |
| Java, Jackson 2.17 default | status = CANCELLED |
| Java, Jackson with STRICT_DUPLICATE_DETECTION | error Duplicate field 'status' |
| Java, org.json 20231013 | error Duplicate key "status" |

Two Java services reading this response disagree: one sees a cancelled order, the other throws, and nobody sees PAID. A schema check still passes. Only the raw text or a strict parser catches the repeat: object_pairs_hook in Python, STRICT_DUPLICATE_DETECTION in Jackson. This response is order 5002 in the [practice API](https://checkcraft.ru/en/guides/api-testing-practice.html).

## Tools to read and check JSON

- [Validate syntax](https://checkcraft.ru/en/guides/json-validator-online.html): finds the line and character of the error.
- [Format](https://checkcraft.ru/en/guides/json-formatter-online.html): pretty-prints or minifies.
- [Open as a tree](https://checkcraft.ru/en/guides/json-viewer-online.html): shows structure and the field path.
- [Compare two JSON documents](https://checkcraft.ru/en/guides/json-compare-online.html): shows changed fields.
- [Extract values with JSONPath](https://checkcraft.ru/en/guides/jsonpath-online.html): selects fields from a large response.
- [Validate against JSON Schema](https://checkcraft.ru/en/guides/json-schema-validator.html): checks the response against a contract.
- [Convert to CSV](https://checkcraft.ru/en/guides/json-to-csv-online.html): opens an export in Excel.

All tools run in the browser and send nothing to a server.

## All guides in the JSON section

- [JSON parse error: what it means and how to fix it](https://checkcraft.ru/en/guides/json-parse-error.html)
- [Unexpected token is not valid JSON: what it means and how to find it](https://checkcraft.ru/en/guides/json-unexpected-token.html)
- [Unexpected end of JSON input: why the JSON ends early](https://checkcraft.ru/en/guides/json-unexpected-end.html)
- [Unexpected token <, <!DOCTYPE is not valid JSON: the server returned HTML](https://checkcraft.ru/en/guides/json-doctype-not-valid.html)
- [Online JSON validator that explains the error](https://checkcraft.ru/en/guides/json-validator-online.html)
- [Format JSON online: pretty print, minify and sort keys](https://checkcraft.ru/en/guides/json-formatter-online.html)
- [Open and view JSON online: tree view and field paths](https://checkcraft.ru/en/guides/json-viewer-online.html)
- [Compare two JSON documents online: added, missing and changed](https://checkcraft.ru/en/guides/json-compare-online.html)
- [JSON to CSV online: a spreadsheet without uploading the file](https://checkcraft.ru/en/guides/json-to-csv-online.html)
- [JSONPath online: test an expression on your JSON](https://checkcraft.ru/en/guides/jsonpath-online.html)
- [Validate JSON against a JSON Schema online](https://checkcraft.ru/en/guides/json-schema-validator.html)
- [Validate required and unexpected JSON fields](https://checkcraft.ru/en/guides/json-required-extra-fields.html)
- [Validate every element of a JSON array](https://checkcraft.ru/en/guides/json-array-validation.html)
- [Decode a JWT online: expiry, payload and signature](https://checkcraft.ru/en/guides/jwt-decode-online.html)

Next step

## Repeat this on your own API

Checkcraft is a desktop app that saves API response checks without code and shows what did not match. Start with a sample, then use your own sanitized data. Free runs on Windows and Linux with no time limit.

[Download Free](https://checkcraft.ru/en/download-checkcraft.html#free-download) · [Download and first run](https://checkcraft.ru/en/download-checkcraft.html)

No sign-up or email needed, the archive is ready in a couple of minutes. See the [edition limits](https://checkcraft.ru/en/pricing.html).

## References

[RFC 8259: the JSON format](https://www.rfc-editor.org/rfc/rfc8259) · [json.org: format description](https://www.json.org/json-ru.html)

## Continue with a related task

[JSON parse error: what it means and how to fix it](https://checkcraft.ru/en/guides/json-parse-error.html) · [Online JSON validator that explains the error](https://checkcraft.ru/en/guides/json-validator-online.html) · [Format JSON online: pretty print, minify and sort keys](https://checkcraft.ru/en/guides/json-formatter-online.html) · [Validate JSON against a JSON Schema online](https://checkcraft.ru/en/guides/json-schema-validator.html) · [JSONPath online: test an expression on your JSON](https://checkcraft.ru/en/guides/jsonpath-online.html)

Start with the linked example and compare its result with your own test requirement.

Ask a person

## Get help with your first test

Tell us what you want to test or where you got stuck. We can help you start Checkcraft, choose an example and understand your first run. You can ask before downloading.

[Ask in Telegram](https://t.me/checkcraftchat)Send an email

The Telegram group is public: do not post passwords, tokens or confidential work data. A description of your task is enough to start.

You can also email us support@checkcraft.ru

Page card: /ai/pages/en/guides/json-format-guide.md
