var person ={"name":"张三","age":23,"gender":true}for(var key in person)//遍历{alert(key+":"+person[key]);//获取键和值 key为字符串格式}
数组格式
var ps =[{"name":"张三","age":23,"gender":true},{"name":"李四","age":24,"gender":true},{"name":"王五","age":25,"gender":false}]for(var i=0; i<ps.length;i++)//遍历{
var p = ps[i];for(var key in p){alert(key+":"+p[key]);}}
嵌套格式
var persons ={"persons":[{"name":"张三","age":23,"gender":true},{"name":"李四","age":24,"gender":true},{"name":"王五","age":25,"gender":false}]};//获取王五的值
var name = persons.persons[2].name
基本格式 var person = {"name":"张三",age:23,"gender":true} for{var key in person}//遍历 { alert(key+":"+person[key]);//获取键和值 key为字符串格式 }数组格式 var ps = [{"name":"张三","age":23,"gender...