2011-07-15 103 views
0

我試圖從這個JSON文件中解析第一個徽標圖像(assets/images/resized/0002/3133/23133v9-max-150x150.png)。從JSON數組中獲取圖像

http://api.crunchbase.com/v/1/company/airbnb.js

我這是怎麼分析的其他數據,但我無法弄清楚如何獲取圖像:

$.ajax({ 
url: "http://api.crunchbase.com/v/1/company/airbnb.js", 
dataType: 'jsonp', 
success: function(results){ 
    var number_of_employees = results.number_of_employees; 
    var founded_month = results.founded_month; 
    var founded_year = results.founded_year; 
    $('#number_of_employees').append(number_of_employees); 
    $('#founded').append(founded_month + '/' + founded_year); 

} 
}); 

任何幫助,不勝感激!

謝謝!

回答

1
$.ajax({ 
url: "http://api.crunchbase.com/v/1/company/airbnb.js", 
dataType: 'jsonp', 
success: function(results){ 
    // ... 
    var imgUrl = 'http://crunchbase.com/' + results.image.available_sizes[0][1]; 
    // Display the image (requires <img id="myImage"/> in the document) 
    $('#myImage').attr('src', imgUrl); 
} 
}); 
1

Accesspattern爲最小的圖像:image.available_sizes[0][1];