Node.js MongoDB使用json2将属性嵌套的JSON转换为CSV

Node.js MongoDB使用json2将属性嵌套的JSON转换为CSV,node.js,reactjs,mongodb,express,Node.js,Reactjs,Mongodb,Express,[这是我的输出,但主题同义词行中包含Hello,Hi。 [我希望我的输出是这样的]] // JSON TO CSV var json = data.content; var fields = Object.keys(json[0]) var replacer = function(key, value) { return value === null ? '' : value } var csv = json.map(function(row){ return fields.map(fun

[这是我的输出,但主题同义词行中包含Hello,Hi。 [我希望我的输出是这样的]]

// JSON TO CSV
var json = data.content;
var fields = Object.keys(json[0])
var replacer = function(key, value) { return value === null ? '' : value } 
var csv = json.map(function(row){
  return fields.map(function(fieldName){
    return JSON.stringify(row[fieldName], replacer)
  }).join(',')
})