码迷,mamicode.com
首页 > Web开发 > 详细

json字符串到js对象的转换

时间:2016-04-15 18:19:08      阅读:152      评论:0      收藏:0      [点我收藏+]

标签:

  window.onload = function () {
            var arrar = ‘{"programmer":[‘+‘{"type":"beijing","jine":"126400","year":"12","qixian":"36"},‘
                        +‘{"type":"shanghai","jine":"126400","year":"12","qixian":"48"},‘
                        +‘{"type":"tianjian","jine":"126400","year":"12","qixian":"48"},‘
                        +‘{"type":"jinan","jine":"70200","year":"12","qixian":"36"},‘
                        +‘{"type":"shenzhen","jine":"70200","year":"12","qixian":"36"},‘
                        +‘{"type":"chongqing","jine":"42100","year":"12","qixian":"36"}]}‘;
            var jsobject=eval("("+arrar+")");
            var lis = document.getElementsByTagName("strong");
            for (var i = 0; i < jsobject.programmer.length; i++) {
            //console.log(arrar[i].jine);
                lis[i].innerHTML = jsobject.programmer[i].jine;
                
            }

 

json字符串到js对象的转换

标签:

原文地址:http://www.cnblogs.com/zhengtu2015/p/5396199.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!