Best input shape
CSV is a table format, so the cleanest JSON input is an array of objects where each object represents one row.
If later objects contain extra fields, those keys are added to the header set so the exported CSV still includes the available data.
- [{"name":"Alice","age":30}] converts directly to a header row and one data row.
- Nested objects are serialized as their JavaScript string representation, so flatten complex data first when exact columns matter.
- Empty arrays produce an empty CSV output.