首页 > Web开发 > 详细

JSON.stringify && JSON.parse

时间:2015-04-10 19:28:20      阅读:309      评论:0      收藏:0      [点我收藏+]
var temp = [1,2,3,4,5];
console.log(‘type:‘,typeof temp); //type: object
console.log(‘length:‘,temp.length);//length: 5
console.log(‘temp[0]:‘,temp[0]);//temp[0]: 1

temp = JSON.stringify(temp); 
console.log(‘type:‘,typeof temp);//type: string
console.log(‘length:‘,temp.length);//length: 11
console.log(‘temp[0]:‘,temp[0]);//temp[0]: [

temp = JSON.parse(temp);
console.log(‘type:‘,typeof temp);//type: object
console.log(‘length:‘,temp.length);//length: 5
console.log(‘temp[0]:‘,temp[0]);//temp[0]: 1

 

JSON.stringify && JSON.parse

原文:http://www.cnblogs.com/Fredric-2013/p/4415092.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!