我有这个数据:
[
[
{"id":"1", "sentiment":"0", "name":"Company 1", "count":"10"},
{"id":"2", "sentiment":"0", "name":"Company 2", "count":"5"},
{"id":"3", "sentiment":"0", "name":"Company 3", "count":"7"}
],
[
{"id":"1", "sentiment":"1", "name":"Company 1", "count":"3"},
{"id":"2", "sentiment":"1", "name":"Company 2", "count":"2"},
{"id":"3", "sentiment":"1", "name":"Company 3", "count":"4"}
]
]
我如何遍历这些数据以获得两个表,如下所示:
id Company sentiment count
1 Company 1 0 10
2 Company 2 0 5
3 Company 3 0 7
id Company sentiment count
1 Company 1 1 3
2 Company 2 1 2
3 Company 3 1 4
我已经开始了,但卡住了:
var obj = JSON.parse(data);
$.each(obj, function(i, obj_item){
$.each(obj_item, function(j, item){
// got stuck here
})
})
任何帮助,将不胜感激。谢谢