我想根據用戶選擇的字段將json值轉換爲平面csv。我的JSON看起來像flattening json格式爲csv
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"
}]
}]
}]
}
}
}};
的Ive能夠收集到所有出現的值,並將其存儲爲CSV,但我想從根本上本身保存的細節..
如果我選擇的時間, CSV輸出應該是什麼樣子,
"test", "news", "propertyFile 9","null", "50", "Events": "Time", "Dec 9", "2012"
是否有可能實現平坦化JSON ..我會添加JSON小提琴鏈接顯示在那裏伊夫這個東西達到.. http://jsfiddle.net/JHCwM/
JSON只是以字符串形式一個JavaScript數據結構。你不直接處理json - 你處理原生javascript數據並從那裏開始工作。 –