📜  json 中的 Jquery 搜索 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:02:04.248000             🧑  作者: Mango

代码示例1
$(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;
        }
    });
});