我有一個json如下。您可以看到same here的樹狀圖。Manipual json與Js
{
"results": {
"collection1": [
{
"property1": {
"href": "http://www.somesite.com/neatobambino/2015/12/29/Little-Girl-Uses-Dogs-Tail-as-a-Paintbrush/",
"text": "Little Girl Uses Dog's Tail as a Paintbrush"
},
"property5": {
"alt": "",
"src": "",
"text": ""
},
"index": 1,
"url": "http://www.somesite.com/"
},
{
"property1": {
"href": "http://www.somesite.com/2015/09/11/20-Alternative-Housing-Solutions-for-the-Homeless/",
"text": "20 Alternative Housing Solutions for the Homeless"
},
"property5": [
{
"alt": "",
"src": "http://www.somesite.com/page/data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=",
"text": ""
},
{
"alt": "",
"src": "http://www.somesite.com/page/data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=",
"text": ""
}
],
"index": 2500,
"url": "http://www.somesite.com/page/84"
}
]
}
}
正如你所看到的結果是兩個層面裏面。在results
裏面,我們再次有collection1
。整個json在一個對象data
內。如何將collection1
中的整個數據直接移動到results
?
有些事情。
var data.results = data.results.collections;
你可以這樣做嗎?
我會試試看。謝謝.. – esafwan