我正在尝试根据用户选择的字段将 json 值转换为平面 csv。我的 json 看起来像
var data = {
"_index": "test",
"_type": "news",
"_source": {
"partnerName": "propertyFile 9",
"relatedSources": "null",
"entityCount": "50",
"Categories": {
"Types": {
"Events": [{
"count": 1,
"term": "Time",
"Time": [{
"term": "Dec 9",
"Dec_9": [{
"count": 1,
"term": "2012"
}]
}]
}, {
"count": 4,
"term": "News",
"News": [{
"term": "Germany",
"Germany": [{
"count": 1,
"term": "Election"
}],
"currency": "Euro (EUR)"
}, {
"term": "Egypt",
"Egypt": [{
"count": 1,
"term": "Revolution"
}]
}]
}]
}
}
}};
我已经能够收集所有出现的值并将其存储为 csv,但我想从根本身保存详细信息..
如果我选择时间,csv 输出应该是这样的,
"test", "news", "propertyFile 9","null", "50", "Events": "Time", "Dec 9", "2012"
是否可以展平 json .. 我将添加 json fiddle 链接以显示我已经用这个东西到达了哪里.. http://jsfiddle.net/JHCwM/