Export a batch of sample person records — generated server-side — as a JSON array, optionally pretty-printed with two-space indentation. JSON is the native format for REST API mocks, Node scripts, and front-end fixtures when you need structured objects rather than a flat table.
How it works
peopleToJson runs JSON.stringify on the person array, dropping nullish fields, with indentation when pretty-print is enabled. Nested objects such as country or municipality remain nested JSON objects (not collapsed into a single string), preserving hierarchy for code that expects person.country.code-style access.
When to use it
- Mock API responses for UI development
- Jest/Playwright fixtures that
JSON.parsesample users - Seed backend test databases with structurally valid but synthetic records
Limitations
Pretty-printed JSON is larger than minified output. Circular references cannot appear (person models are trees). Field order follows object enumeration and may differ from CSV column order. Batch size is capped server-side by the same limits as the generator subtool.
Example
A single pretty-printed record resembles:
[
{
"firstName": "Ada",
"lastName": "Lovelace",
"gender": "F",
"birthDate": "1815-12-10",
"email": "ada@example.com"
}
]
Minified mode emits the same structure on one line without indentation.