0
我正在使用jQuery来解析和显示来自JSON文件的数据。我在浏览器中吐出了一切,但我的JSON文件中的一个键具有一组值。因此,例如,这是我的JSON:如何使用jQuery显示带有数组的JSON对象
{
"category" : "Stuff",
"location_id" : {
"longitude" : "-71.89237903999964",
"latitude" : "41.6809076720005",
"human_address" : "{\"address\":\"156 Plainfield Pike Rd\",\"city\":\"Plainfield\",\"state\":\"CT\",\"zip\":\"06374\"}"
},
}
这里是我的jQuery代码:
$.getJSON('data.json', function(data) {
var output = '<ul class="searchresults">';
$.each(data, function(key, val) {
if (val.item.search(myExp) != -1) {
output += '<li>';
output += '<p>' + "Category: " + val.category + '</p>';
output += '<p>' + "Location: " + val.location_id + '</p>';
output += '<p>' + "Business: " + val.business + '</p>';
output += '</li>';
}
});
output += '</ul>';
$('#update').html(output);
我由于某种原因,输出为LOCATION_ID出来作为[目标,对象] ...能有人帮我抓住阵列中的一切?
谢谢一堆!