当前位置: 代码迷 >> JavaScript >> 遍历一个json数组添json对象的字符串
  详细解决方案

遍历一个json数组添json对象的字符串

热度:226   发布时间:2013-03-22 09:49:50.0
遍历一个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);
});
});
});
  相关解决方案