2014-02-25 55 views
-3

嗨,我的Json看起來像下面,我想解析它來將數據綁定到數組。請提供我如何解析它?如何在jQuery或AngularJS中解析json數組數組

[ 
    { 
    "ImgUrl": "http://www.cowboysalamocityharley.com/used_bikes/DSC_7815.JPG", 
    "CarouselImages": [ 
     "http://www.cowboysalamocityharley.com/used_bikes/th_DSC_7816.JPG", 
     "http://www.cowboysalamocityharley.com/used_bikes/th_DSC_7817.JPG", 
     "http://www.cowboysalamocityharley.com/used_bikes/th_DSC_7818.JPG", 
     "http://www.cowboysalamocityharley.com/used_bikes/th_DSC_7819.JPG", 
     "http://www.cowboysalamocityharley.com/used_bikes/th_DSC_7820.JPG", 
     "http://www.cowboysalamocityharley.com/used_bikes/th_DSC_7821.JPG", 
     "http://www.cowboysalamocityharley.com/used_bikes/th_DSC_7822.JPG" 
    ], 
    "VehicleId": 1 
    }, 
    { 
    "ImgUrl": "http://www.cowboysalamocityharley.com/used_bikes/DSC_7816.JPG", 
    "CarouselImages": [ 
     "http://www.cowboysalamocityharley.com/used_bikes/th_DSC_7816.JPG", 
     "http://www.cowboysalamocityharley.com/used_bikes/th_DSC_7817.JPG", 
     "http://www.cowboysalamocityharley.com/used_bikes/th_DSC_7818.JPG", 
     "http://www.cowboysalamocityharley.com/used_bikes/th_DSC_7819.JPG", 
     "http://www.cowboysalamocityharley.com/used_bikes/th_DSC_7820.JPG", 
     "http://www.cowboysalamocityharley.com/used_bikes/th_DSC_7821.JPG", 
     "http://www.cowboysalamocityharley.com/used_bikes/th_DSC_7822.JPG" 
    ], 
    "VehicleId": 2 
    }, 
    { 
    "ImgUrl": "http://www.cowboysalamocityharley.com/used_bikes/DSC_7817.JPG", 
    "CarouselImages": [ 
     "http://www.cowboysalamocityharley.com/used_bikes/th_DSC_7816.JPG", 
     "http://www.cowboysalamocityharley.com/used_bikes/th_DSC_7817.JPG", 
     "http://www.cowboysalamocityharley.com/used_bikes/th_DSC_7818.JPG", 
     "http://www.cowboysalamocityharley.com/used_bikes/th_DSC_7819.JPG", 
     "http://www.cowboysalamocityharley.com/used_bikes/th_DSC_7820.JPG", 
     "http://www.cowboysalamocityharley.com/used_bikes/th_DSC_7821.JPG", 
     "http://www.cowboysalamocityharley.com/used_bikes/th_DSC_7822.JPG" 
    ], 
    "VehicleId": 3 
    }, 
    { 
    "ImgUrl": "http://www.cowboysalamocityharley.com/used_bikes/DSC_7818.JPG", 
    "CarouselImages": [ 
     "http://www.cowboysalamocityharley.com/used_bikes/th_DSC_7816.JPG", 
     "http://www.cowboysalamocityharley.com/used_bikes/th_DSC_7817.JPG", 
     "http://www.cowboysalamocityharley.com/used_bikes/th_DSC_7818.JPG", 
     "http://www.cowboysalamocityharley.com/used_bikes/th_DSC_7819.JPG", 
     "http://www.cowboysalamocityharley.com/used_bikes/th_DSC_7820.JPG", 
     "http://www.cowboysalamocityharley.com/used_bikes/th_DSC_7821.JPG", 
     "http://www.cowboysalamocityharley.com/used_bikes/th_DSC_7822.JPG" 
    ], 
    "VehicleId": 4 
    } 
] 

有沒有什麼辦法可以使用內置庫解析,還是需要循環?

+2

你說的解析是什麼意思? – Satpal

回答

0

試試這個

var json = eval("(" + result + ")"); 
0

試試這個:

var arr = JSON.parse(data);