convert json to csv

PHOTO EMBED

Wed Aug 31 2022 20:01:11 GMT+0000 (Coordinated Universal Time)

Saved by @elias #javascript

const items = json
const replacer = (key, value) => value === null ? '' : value 
const header = Object.keys(items[0])
const csv = [
  header.join(','), // header row first
  ...items.map(row => header.map(fieldName => JSON.stringify(row[fieldName], replacer)).join(','))
].join('\r\n')

console.log(csv)
content_copyCOPY