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

js解析json格式

时间:2015-05-26 10:37:37      阅读:145      评论:0      收藏:0      [点我收藏+]

标签:

 

 function save(){
    			var value2 = { 
			    "china":[ 
			        {"name":"hangzhou", "item":"1"}, 
			        {"name":"shanghai", "item":"2"}, 
			        {"name":"sichuan", "item":"3"} 
			    ], 
			    "America":[ 
			        {"name":"aa", "item":"12"}, 
			        {"name":"bb", "item":"2"} 
			    ], 
			    "Spain":[ 
			        {"name":"cc", "item":"1"}, 
			        {"name":"dd", "item":"23"}, 
			        {"name":"ee", "item":"3"} 
			    ] 
			}; 			
			
			for (var countryObj in value2) 
			{ 
			    document.write(countryObj + ":<br />") 
			    for (var cityObj in value2[countryObj]) 
			    { 
			        //可以用document.write("-----" + value2[countryObj][cityObj].item + "<br />"); 
			        document.write(cityObj + " ++++++ " + value2[countryObj][cityObj]["name"] + "<br />" ); 
			    } 
			}
    	}

  

js解析json格式

标签:

原文地址:http://www.cnblogs.com/estellez/p/4529902.html

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