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

json 里的stringify parse的方法

时间:2017-09-05 22:05:09      阅读:202      评论:0      收藏:0      [点我收藏+]

标签:doc   htm   set   title   parse   tle   har   rip   typeof   

<!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的方法

标签:doc   htm   set   title   parse   tle   har   rip   typeof   

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

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