我想知道是否有人可以提供帮助。我正在使用jQuery,我有一些看起来像这样的JSON。
[
{
"NEW": {
"timestamp": 1376735750000,
"title": "Lorem ipsum 2013-08-17T10:35:50+00:00",
"date": "Sat, 17 Aug 2013 10:35:50 GMT",
"description": "Laborum ex sit elit occaecat pariatur consectetur id amet duis magna ex pariatur.",
"link": "http://example.com/test/1376735750"
}
},
{
"NEW": {
"timestamp": 1376735740000,
"title": "Lorem ipsum 2013-08-17T10:35:40+00:00",
"date": "Sat, 17 Aug 2013 10:35:40 GMT",
"description": "Eiusmod sunt aliqua in eu tempor.",
"link": "http://example.com/test/1376735740"
}
},
{
"NEW": {
"timestamp": 1376735730000,
"title": "Lorem ipsum 2013-08-17T10:35:30+00:00",
"date": "Sat, 17 Aug 2013 10:35:30 GMT",
"description": "Id ex deserunt dolor minim minim tempor incididunt cillum ad officia.",
"link": "http://example.com/test/1376735730"
}
}
]
我想将它从NEW中移出并进入父级别。
[
{
"timestamp": 1376735750000,
"title": "Lorem ipsum 2013-08-17T10:35:50+00:00",
"date": "Sat, 17 Aug 2013 10:35:50 GMT",
"description": "Laborum ex sit elit occaecat pariatur consectetur id amet duis magna ex pariatur.",
"link": "http://example.com/test/1376735750"
},
{
"timestamp": 1376735740000,
"title": "Lorem ipsum 2013-08-17T10:35:40+00:00",
"date": "Sat, 17 Aug 2013 10:35:40 GMT",
"description": "Eiusmod sunt aliqua in eu tempor.",
"link": "http://example.com/test/1376735740"
},
{
"timestamp": 1376735730000,
"title": "Lorem ipsum 2013-08-17T10:35:30+00:00",
"date": "Sat, 17 Aug 2013 10:35:30 GMT",
"description": "Id ex deserunt dolor minim minim tempor incididunt cillum ad officia.",
"link": "http://example.com/test/1376735730"
}
]
任何在哪里看都会非常感激。
答案 0 :(得分:1)
var new_array = [];
for(var i = 0; i < your_array.length; i++){
new_array.push(your_array[i]['NEW']);
}