7 min read
2026-03-07
JSON Schema allows you to set rules for structure and data types:
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"required": ["name", "age"],
"properties": {
"name": { "type": "string", "minLength": 1 },
"age": { "type": "integer", "minimum": 0, "maximum": 150 },
"email": { "type": "string", "format": "email" }
}
}JSONPath is an analogue of XPath for JSON:
| Expression | Meaning |
|---|---|
| `$.store.book[*].author` | All book authors |
| `$..price` | All prices (recursive) |
| `$.book[?(@.price < 10)]` | Books cheaper than 10 |
| `$.book[-1:]` | Last book |
For files over 10 MB, use streaming parsing:
**Node.js (stream-json):**
const { parser } = require('stream-json');
const { streamValues } = require('stream-json/streamers/StreamValues');
fs.createReadStream('large.json')
.pipe(parser())
.pipe(streamValues())
.on('data', ({ value }) => processItem(value));**Trailing comma** - extra comma at the end of the array/object
**Single quotes** - JSON requires double quotes
**undefined** - is not a valid JSON value
**NaN/Infinity** - not supported, replace with null
Always return Content-Type: application/json
Use camelCase for keys in JavaScript API
Wrap collections: `{"data": [...], "meta": {...}}`
Version the API: `/api/v1/resource`
Format and validate JSON in JSON Formatter.
See also: YAML ↔ JSON, XML Formatter, Test Data Generator