我正在开发一个需要从数据结构转换到另一个数据结构的项目。你会怎么做这个家伙?由此:
var json=[{"created_at":1385481173,"ranking":[["#OBAMA",88],["#TCOT",82]]},{"created_at":1385481233,"ranking":[["#OBAMA",86],["#TCOT",62]]},{"created_at":1385481293,"ranking":[["#OBAMA",82],["#TCOT",42]]},{"created_at":1385481353,"ranking":[["#OBAMA",67],["#TCOT",62]]},{"created_at":1385481413,"ranking":[["#OBAMA",88],["#TCOT",22]]}];
对此: http://pastebin.com/eTGWbARv
chart_data = [{
"tag": "obama",
"points": [{
"created_at": 1385481173,
rate: 27,
tag: "obama"
}, {
"created_at": 1385481233,
rate: 28,
tag: "obama"
}, {
"created_at": 1385481293,
rate: 23,
tag: "obama"
}, {
"created_at": 1385481353,
rate: 25,
tag: "obama"
}, {
rate: 10,
tag: "obama",
"created_at": 1385481413
}]
},
{
"tag": "tcot",
"points": [{
"created_at": 1385481173,
rate: 27,
tag: "tcot"
}, {
"created_at": 1385481233,
rate: 28,
tag: "tcot"
}, {
"created_at": 1385481293,
rate: 29,
tag: "tco"
}, {
"created_at": 1385481353,
rate: 23,
tag: "tcot"
}, {
"created_at": 1385481413,
rate: 25,
tag: "tcot"
}]
}];