标签:logs nbsp rip 数据 ima json对象 fine http 方法
循环json对象的值
var json1 = { "name": "jiao", "age": 25, "man": true, "things": { "thing1": "violin", "thing2": "coding" } } for(attr in json1){ console.log(json1[attr]); }
json对象中数据的修改
var json1 = { "name": "jiao", "age": 25, "man": true, "things": { "thing1": "violin", "thing2": "coding" } } delete json1.things.thing1; json1.things.thing3 = "haha"; console.log(json1.things);
json数组
var json1 = { "name": "jiao", "age": 25, "man": true, "things": { "thing1": "violin", "thing2": "coding" }, "arr": [ "site1", "site2", "site3", "site4" ] } for(var i = 0; i < json1.arr.length; i++){ console.log(json1.arr[i]); }
教程中说可以使用delete关键字删除数组元素。可我删除了之后数组长度不变,被删除的元素变为undefined,占位仍在。
似乎只能用正常的数组方法来解决这个问题了。
标签:logs nbsp rip 数据 ima json对象 fine http 方法
原文地址:http://www.cnblogs.com/jiaoxuanwen/p/7040302.html