js如何获取以下数组的名Name,mobile
[{"Id":"8a948bf24a510afa0","Name":"cc","Type":"YY","attributes":{"email":"","mobile":...
[{ "Id" : "8a948bf24a510afa0", "Name" : "cc", "Type" : "YY", "attributes" : { "email" : "", "mobile" : "123",}, "parentId" : "8A948A5148EF6F000A"},
{ "Id" : "8acsdasdsad0", "Name" : "gg", "Type" : "YY", "attributes" : { "email" : "", "mobile" : "333",}, "parentId" : "8A948A5148EF6F000A"}] 展开
{ "Id" : "8acsdasdsad0", "Name" : "gg", "Type" : "YY", "attributes" : { "email" : "", "mobile" : "333",}, "parentId" : "8A948A5148EF6F000A"}] 展开
1个回答
展开全部
var text=[{ "Id" : "8a948bf24a510afa0", "Name" : "cc", "Type" : "YY", "attributes" : { "email" : "", "mobile" : "123",}, "parentId" : "8A948A5148EF6F000A"},
{ "Id" : "8acsdasdsad0", "Name" : "gg", "Type" : "YY", "attributes" : { "email" : "", "mobile" : "333",}, "parentId" : "8A948A5148EF6F000A"}];
var last="";
for(var i=0;i<text.length;i++){
for(var ii in text[i]){
if(ii=="Name"||ii=="mobile"){
last+=text[i][ii];
}
for( var jj in text[i][ii]){
if(jj=="mobile"||jj=="Name"){
last+=text[i][ii][jj];
}
}
}
}
}
alert(last);
{ "Id" : "8acsdasdsad0", "Name" : "gg", "Type" : "YY", "attributes" : { "email" : "", "mobile" : "333",}, "parentId" : "8A948A5148EF6F000A"}];
var last="";
for(var i=0;i<text.length;i++){
for(var ii in text[i]){
if(ii=="Name"||ii=="mobile"){
last+=text[i][ii];
}
for( var jj in text[i][ii]){
if(jj=="mobile"||jj=="Name"){
last+=text[i][ii][jj];
}
}
}
}
}
alert(last);
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询