{
"data": [
[
{
"Id": 2,
"Name": "name",
"city": "Delhi",
"location": "Anand Vihar",
"landmark": null,
"pincode": 100221,
"profilePic": null,
"emailId": "email@gmail.com",
"membershipName": null
][
{
"Id": 2,
"Name": "name",
"city": "Delhi",
"location": "Anand Vihar",
"landmark": null,
"pincode": 100221,
"profilePic": null,
"emailId": "email@gmail.com",
"membershipName": null
]
]
}
我有上面的json格式。请帮助我从jquery接受。
答案 0 :(得分:0)
正如上面提到的那样,首先构建proper json data
。如下所示,然后迭代它来处理每个。测试json数据访问:http://json.parser.online.fr/
<script>
var json='{"data": [[{"Id": 2,"Name": "name","city": "Delhi","location": "Anand Vihar","landmark": null,"pincode": 100221,"profilePic": null,"emailId": "email@gmail.com","membershipName": null},{"Id": 2,"Name": "name","city": "Delhi","location": "Anand Vihar","landmark": null,"pincode": 100221,"profilePic": null,"emailId": "email@gmail.com","membershipName": null}]]}';
var json=JSON.parse(json);
for(x in json['data'][0]){//you can use each also.
console.log(json['data'][0][x]);//it will log each data set get the attributes to use
}
</script>
答案 1 :(得分:0)
var uData =data.data;
for(var i in uData)
{
var rd = $('<tr class=""></tr>');
var o=uData[i];
for(var j in o)
{
rd.append('<td>'+o[j]+'</td>');
$('#example').append(rd);
}
}
小心JSON阵列结构