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

JSON.stringify && JSON.parse

时间:2015-04-10 19:30:09      阅读:148      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!