我在jquery中做了一個ajax請求,並返回響應但不是數組。如何在數組中使用json響應
{"ErrorCode":0,"SeriesSocialStats":{"8970471":{"faves":1,"friendFaves":0,"friendLikes":0,"likes":1,"myFaves":1,"myLikes":0,"seriesId":"8970471"}}}
{"ErrorCode":0,"SeriesSocialStats":{"184072":{"faves":2,"friendFaves":0,"friendLikes":0,"likes":2,"myFaves":1,"myLikes":0,"seriesId":"184072"}}}
我要合併上述兩個反應,並創建一個數組是這樣的:
{"faves":1,"friendFaves":0,"friendLikes":0,"likes":1,"myFaves":1,"myLikes":0,"seriesId":"8970471"},{"faves":2,"friendFaves":0,"friendLikes":0,"likes":2,"myFaves":1,"myLikes":0,"seriesId":"184072"}
請建議如何做到這一點。我想把它放在數組中,並在本地存儲它可能在配置變量get:[]
,然後訪問有點像config.get[data["seriesId"]]
。
您可以從更改服務器如何使用JSON回覆開始。首先將該答覆轉換爲數組。你不能像這樣解析JSON。 – Joseph 2012-04-06 12:50:33
但如何做到這一點,因爲我需要跳過'「8970471」:'從每個響應。此外,我無法訪問該部分後的響應,因爲這是seriesId,我不能給它手動 – user850234 2012-04-06 13:02:33