lxfp.net
当前位置:首页 >> js jsonArrAy 遍历 >>

js jsonArrAy 遍历

var typeArr = new Array();for(var i = 0;i

jq框架下,给个示例,仅供参考: var objs = $.parseJSON('[{"name":"aaa","age":"22"},{"name":"bbb","age":"33"}]');var str = '';$.each(objs, function(k, obj){ str += obj.name + ' is ' + obj.age + "\n";});alert(str);

var data = [{ id: 0, chiild: [{ msg: '111' }, { msg: '222'}] }, { id: 3, chiild: [{ msg: '444' }, { msg: '555'}] }, { id: 2, chiild: [{ msg: '467' }, { msg: '58912'}]}]; var str = ""; var strmsg = ""; for (var i = 0; i < data....

json.a[1],还有你的这个json是有问题的,数组不要用‘’号引起来! var json={ a:["aaaaa","bbbbb","ccccc"], b:["11111","22222","33333"] };

既然隔壁问题已经解决了.. 就把这个问题也解决了吧~

var obj = {};for(var k in obj) { //遍历对象,k即为key,obj[k]为当前k对应的值 console.log(obj[k]);}

看这样一段函数定义的代码就明白了function json_to_format_string(obj,deep){var html = "";var blank_string = "";for (var i = 0; i < deep; i++) {blank_string += " ";};for(var name in obj){if (typeof(obj[name])=="object") {html += b...

var Sum = function(List,Field){var S = 0,T,F;for (F = 0;F < List.length;++F){T = List[F]T.children && (T[Field] += Sum(T.children,Field))S += T[Field]}return S},F;for (F = b.length;F--;){switch (b[F].type){case 'sum' : Sum(a,b[...

var list = {"id":1,"key":101,"value":"value"};var str = "";for(var name in list){ str+=name+"="+list[name].toString();}alert(str);

例如数据库里面的json字符串是这样的 ? 1 2 3 4 5 var str = '[{"name":"宗2瓜","num":"1","price":"122"},{"name":"宗呱呱","num":"1","price":"100"}]'; var xqo = eval('(' + str + ')'); for(var i in xqo){ alert(xqo[i].name); } 上面的是...

网站首页 | 网站地图
All rights reserved Powered by www.lxfp.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com