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 |
|---|---|---|
currency | string | An ISO 4217 code such as EUR. State it once for the whole document. |
products[].sku | string | Stock keeping unit, a stable identifier for each product. |
products[].price | number | Shown as a decimal here; see the tip about money. |
products[].variants | array | Empty when a product has no options. |
products[].dimensions | object | Grouped measurements with the unit in the key name. |
Read it in code
JavaScript:
const inStock = data.products.filter((p) => p.inStock).map((p) => p.name);Python:
in_stock = [p["name"] for p in data["products"] if p["inStock"]]What this example is good for
- Prototyping a shop front end
- Practising filters: JSONPath $.products[?(@.inStock == true)].name
- Converting to CSV for a spreadsheet
Tips
- Floating-point numbers are risky for money (0.1 + 0.2 is not 0.3). Many APIs send prices as integer cents or as strings.
- Put the unit in the key name (heightCm) so it cannot be misread.
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