var json = { "people": { "person": [{ "name": "Peter", "age": 43, "sex": "male"}, { "name": "Zara", "age": 65, "sex": "female"}] }};$.each(json.people.person, function(i, v) { if (v.name == "Peter") { alert(v.age); return; }});
根据此答案,您可以使用类似:
$(function() { var json = { "people": { "person": [{ "name": "Peter", "age": 43, "sex": "male"}, { "name": "Zara", "age": 65, "sex": "female"}] } }; $.each(json.people.person, function(i, v) { if (v.name.search(new RegExp(/peter/i)) != -1) { alert(v.age); return; } });});
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)