赞
踩
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
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。