[ { “id”:2, “名字”:“冰雕”, “价格”:12.50, },
{ “id”:3, “名字”:“蓝鼠”, “价格”:25.50, } ]
答案 0 :(得分:0)
Json对象:
var data = [
{
"id": 2,
"name": "An ice sculpture",
"price": 12.50
},
{
"id": 3,
"name": "A blue mouse",
"price": 25.50
}
];
迭代对象的每个属性:
var htmlContent = '';
for ( var key in data ) {
htmlContent += '<div class="container">';
htmlContent += '<p> Name: ' + data[key].name + '</p>';
htmlContent += '<p> Price: ' + data[key].ptice + '</p>';
htmlContent += '</div>';
}
$('body').append(htmlContent);
答案 1 :(得分:0)
$json = @file_get_contents($url); $data = json_decode($json);
如何从此链接接收数据。