小台的IT备忘录  
脑子越来越不好用,只能依靠烂笔头了~

<script src="~/static/js/jquery.min.js"></script>
<script type="text/javascript">
var list = [];//创建数组
var a1 = {};//创建对象
a1.t = "a";
a1.v = "b,s,g";
var a2 = {};
a2.t = "c";
a2.v = "d,h,e";
list.push(a1);//添加对象
list.push(a2);

var j = JSON.stringify(list);//将对象转换为json
console.log(j);

alert(j);

//将字符串转换为json对象

JSON.parse('[{"t":"a","v":"b,s,g"},{"t":"c","v":"d,h,e"}]');
</script>

posted on 2016-07-12 14:51  taiyonghai  阅读(7716)  评论(0编辑  收藏  举报