日期:2014-05-16  浏览次数:20304 次

遍历一个json数组加json对象的字符串
{
"b":
  [{"userName":"爸爸","tel":"123456"},{"userName":"妈妈","tel":"123456"}],
"c":
  [{"userName":"陈总","tel":"123456"},{"userName":"成刚","tel":"123456"}],
"d":
  [{"userName":"123","tel":"123456"},{"userName":"123","tel":"123456"}],
"e":
  [{"userName":"123","tel":"123456"},{"userName":"123","tel":"123456"}],
"f":
  [{"userName":"123","tel":"123456"},{"userName":"123","tel":"123456"}]
}
在jsp中用$.each()来遍历下
或者其他的方法

------解决方案--------------------
遍历得到什么结果?
------解决方案--------------------

$(function(){
var data = {
"b":
  [{"userName":"爸爸","tel":"123456"},{"userName":"妈妈","tel":"123456"}],
"c":
  [{"userName":"陈总","tel":"123456"},{"userName":"成刚","tel":"123456"}],
"d":
  [{"userName":"123","tel":"123456"},{"userName":"123","tel":"123456"}],
"e":
  [{"userName":"123","tel":"123456"},{"userName":"123","tel":"123456"}],
"f":
  [{"userName":"123","tel":"123456"},{"userName":"123","tel":"123456"}]
};
$.each(data , function(){
$.each(this , function(){
alert(this.userName + " " + this.tel);
});
});
});