json js

转:http://www.cnblogs.com/worfdream/articles/1956449.html
http://zhidao.baidu.com/link?url=Ozbqc9Q1Vt5o2BjecyW4lKKK6JBhLzxbPXRtYbGCNHX6s_Zjdn1dFCu-aZdH5Hv1SSZm1Dl-iC4GTzBRDz7tNK
http://lzw.me/a/html5-localstorage.html
<script>
var jsonstr = '{ "name": "cxh", "sex": "man" }';
alert(typeof(jsonstr));
var obj = JSON.parse(jsonstr); //由JSON字符串转换为JSON对象
alert(typeof(obj));
var obj = eval('(' + jsonstr + ')');
alert(typeof(obj));
var str2 = { "name": "cxh", "sex": "man" };
alert(typeof(str2));
alert(str2.name);
var jsonstr="[{'name':'a','value':1},{'name':'b','value':2}]";
var jsonarray = eval('('+jsonstr+')');
var arr =
{
"name" : "test",
"value" : 100
}
jsonarray.push(arr);
console.log(jsonarray);
</script>

    A+
发布日期:2015年04月21日  所属分类:未分类

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: