首页 > Web开发 > 详细

json 里的stringify parse的方法

时间:2017-09-05 21:42:38      阅读:305      评论:0      收藏:0      [点我收藏+]

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>转换</title>
<script>
//stringify:把一个对象转换成对应的字符串
// var arr = [1,2,3,4]
// alert(typeof arr)
// alert(JSON.stringify(arr))
// alert(typeof JSON.stringify(arr))

// var j={left:100}
// alert(typeof j)
// alert(JSON.stringify(j))
// alert(typeof JSON.stringify(j))

//parse:把字符串转换成对应的对象
// var s1="[1,2,3,4,5]";
// alert(typeof s1)
// alert(JSON.parse(s1))
// alert(typeof JSON.parse(s1))


var s2=‘{"left":100}‘
alert(typeof s2)
alert(JSON.parse(s2))
alert(typeof JSON.parse(s2))

</script>
</head>
<body>
</body>
</html>

json 里的stringify parse的方法

原文:http://www.cnblogs.com/mylove0/p/7481832.html

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