Using JSON to CSV: practical guide
Shape your JSON first
CSV is a flat table, so JSON works best as an array of objects with the same keys: each object becomes a row and each key becomes a column. Nested objects and arrays do not fit neatly and may need flattening first.
Check the output in a spreadsheet
Open the CSV in a spreadsheet and look for columns that are missing, because objects with different keys can produce uneven rows. Long numbers such as IDs can be shown in scientific notation by spreadsheets, so format those columns as text.