我想根据用户选择的字段将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数据并从那里开始工作。 –