The example
The JSON above is the example. Explore it in the Tree tab, press Download to save it as a .json file, or Share to send someone a link to it. All names, ids, emails and values are invented.
Fields explained
| Path | Type | Notes |
|---|---|---|
numbers | array of numbers | Every item has the same type. |
colors | array of strings | Strings in double quotes, separated by commas. |
mixed | array | JSON arrays may mix types, including objects and other arrays. Avoid this in APIs, it is hard to type. |
records | array of objects | The most common shape in real APIs: a list of similar records. |
empty | array | An empty list is valid and often means no results. |
Read it in code
JavaScript:
const ids = data.records.map((r) => r.id); // [1, 2]
const last = data.numbers[data.numbers.length - 1]; // 8Python:
ids = [r["id"] for r in data["records"]] # [1, 2]
last = data["numbers"][-1] # 8What this example is good for
- Practising array access and iteration
- Testing converters on lists of records
- Showing how JSONPath wildcards select items
Tips
- Array positions start at 0.
- Records in one array should share the same keys to keep code simple.
Convert this example
Open it in a converter, then switch the output in the Code tab:
- JSON to TypeScript
- JSON to Zod
- JSON to Python (Pydantic)
- JSON to Go
- JSON to JSON Schema
- JSON to CSV
- JSON to YAML
- JSON to XML