2011-11-03 111 views
2

可能重複:
Parse JSON with jQuery我該如何解析JSON?

我試圖解析以下JSON文件。我需要從JSON文件中獲取拇指ID,但我不知道如何去做。我如何使用jQuery或JavaScript解析以下JSON?

[ 

{ 
    "Page": { 
     "number": "0", 
     "thumb": "http:\/\/cdn.data.com\/files\/aT00NTA0NCZwPTAmdmVyc2lvbj0xJmNtZD12JnNpZz0wNmRiZDQxM2I5MTdhYzZjNzJkYThhYWMyNGZlMmY0Zg%253D%253D\/-w-320.jpg" 
    } 
}, { 
    "Page": { 
     "number": "1", 
     "thumb": "http:\/\/cdn.data.com\/files\/aT00NTA0NCZwPTEmdmVyc2lvbj0xJmNtZD12JnNpZz05YWI4ODVmNzZhYmQ0NWYxZmRhMmYwZmJkN2U4OTllMA%253D%253D\/-w-320.jpg" 
    } 
}, { 
    "Page": { 
     "number": "2", 
     "thumb": "http:\/\/cdn.data.com\/files\/aT00NTA0NCZwPTImdmVyc2lvbj0xJmNtZD12JnNpZz1iNjA5NjJjYjIyZDQ3MjY2NWFlZDZkYzczMTdkNmMzNA%253D%253D\/-w-320.jpg" 
    } 
}, { 
    "Page": { 
     "number": "3", 
     "thumb": "http:\/\/cdn.data.com\/files\/aT00NTA0NCZwPTMmdmVyc2lvbj0xJmNtZD12JnNpZz01MjY0OGMwN2MwZWJhZDYyODFjZjJhNDgxNGQ2MTIxYg%253D%253D\/-w-320.jpg" 
    } 
}, { 
    "Page": { 
     "number": "4", 
     "thumb": "http:\/\/cdn.data.com\/files\/aT00NTA0NCZwPTQmdmVyc2lvbj0xJmNtZD12JnNpZz03YTAzNWE5OGVmMDFmYTgxY2Q2OTVlZTc2OGFjNTM1Mw%253D%253D\/-w-320.jpg" 
    } 
} 

] 
+3

谷歌'的jQuery解析json' –

回答

5

試試這個:

var jsonObj = $.parseJSON(theJsonString); 
console.log(jsonObj[0].Page.thumb); 
1

使用jQuery:

$.getJSON('ajax/test.json', function(data) { 
    $.each(data, function(key, val) { 
     //insert your code here 
    }); 
    });