How is the order of JSON object keys handled?
CSV column order is based on the key order in the first JSON object, then any new keys appearing in subsequent objects are added. This ensures all data is included while maintaining consistent column ordering.
What if objects contain nested structures?
Nested objects and arrays are converted to their JSON string representation. For example, {"address": {"city": "Beijing"}} will appear as a string of the entire nested object in the CSV. It's recommended to flatten complex structures first or use specialized data processing tools.
How are commas and quotes handled in CSV?
Values containing commas, quotes, or newlines are automatically enclosed in double quotes, and internal quotes are escaped (doubled). This complies with the CSV standard (RFC 4180), ensuring data displays correctly in spreadsheet software.
Can empty arrays or empty objects be converted?
Empty arrays generate CSV with no data rows (headers only). Arrays containing empty objects generate empty rows. Completely empty input displays an error message.
Can converted CSV be converted back to JSON?
Yes, but some information may be lost, especially nested structures and data type information. Numbers might be treated as strings, and nested objects are flattened to string representations. CSV to JSON conversion requires additional data type inference.