从JSON对返回字符串

问题描述 投票:0回答:1

在JSON对{“string”:“value”}中,我试图返回字符串。我需要发送什么JSONPath查询?作为一个例子,在下面的JSON中,我希望我的查询返回数组中第一行的“类别”一词。

谢谢!托本

{
    "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
1个回答
0
投票

查询是:$ .store.book [:1] .category

[:1] = The item on Position 1
[0:3] = The item on position 1,2,3
[2:4] = The item on position 3,4
© www.soinside.com 2019 - 2024. All rights reserved.