php 无限级数据JSON格式及JS解析

2019-04-09 17:27:06于海丽

for (var one in obj)
{
for(var key in obj[one])
{
index++;
if(key=="fchilds"&&obj[one][key]['invitezcount']!=0){
var aqi = qi;
if(index>1)aqi+="     "
GetShow(obj[one][key],aqi,index)
}
if(key != 'fchilds'){
if(key=="fuid"){
str += qi+key+"="+obj[one][key] + ",";
}else{
str += key+"="+obj[one][key] + ",";
}
if(key == "furl"){
str+="<br/>";
}
}
}
if(one=="invitezcount"||one=="invitecount"){
str+=qi+one+"="+obj[one]+"<br/>";
}
}
}
//固定参数do=charadegarden&action=getinfo&invite=1,fuid为测试时使用,不填写将调用系统当前登录的用户ID
var url = 'http://localhost/home/space.php?do=charadegarden&action=getinfo&invite=1&fuid=344';
$.get(url,function(html){
//获得json并转为对象
if(html){
var obj = eval("["+html+"]");
GetShow(obj[0],"",1)
document.write(str);
document.write("<br/><br/><br/><br/>");
document.write("<b>JSON格式:</b><br/>");
document.write(html);
}
});
</script>

这样,两个无限级的操作就完成了,结果截图:

珍惜劳动成果,虽说内容不多,可是也是一个一个字打上的,转载请注明!!关注爱拼可乐吧

相关文章 大家在看