根据搜索参数使用JSONPath搜索json

时间:2018-09-11 06:25:20

标签: javascript jquery json jsonpath

我有一个杰森说

{
"store": {
    "book": [
        {
            "category": "reference",
            "author": "Nigel Rees",
            "title": "Sayings of the Century",
            "price": 8.95
        },
        {
            "category": "fiction",
            "author": "Evelyn Waugh",
            "title": "Sword of Honour",
            "price": 12.99
        },
        {
            "category": "fiction",
            "author": "Herman Melville",
            "title": "Moby Dick",
            "isbn": "0-553-21311-3",
            "price": 8.99
        },
        {
            "category": "fiction",
            "author": "J. R. R. Tolkien",
            "title": "The Lord of the Rings",
            "isbn": "0-395-19395-8",
            "price": 22.99
        }
    ],
    "bicycle": {
        "color": "red",
        "price": 19.95
    }
},
"expensive": 10
}

我有一个搜索参数,用户可以根据我的json键的值输入。我需要使用JSONPath检查搜索参数是否出现在json中。我的Json可能包含另一个json数组或对象,因此我必须对所有它们进行搜索。有没有更快的方法可以搜索json?

0 个答案:

没有答案