无法以点表示法提取 JsonPath

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

鉴于以下 Json

{
"store": {
    "book": [
        {
            "category": "reference",
            "author": "Nigel Rees",
        },
        {
            "category": "fiction",
            "author": "Evelyn Waugh",
        },
        {
            "category": "fiction",
            "author": "Herman Melville",
            "price": 8.99
        },
        {
            "category": "fiction",
            "author": "J. R. R. Tolkien",
        }
    ],
    "bicycle": {
        "color": "red",
    }
},
"expensive": 10
}

我正在使用下面的配置来提取所有作者的书的 json 路径

Configuration conf = Configuration.builder().options(Option.AS_PATH_LIST).build();
Object read = JsonPath.using(conf).parse(jsonStringRaw).read("$.store.book[*].author");

我得到以下括号中的输出 - 符号

"$['store']['book'][0]['author']"
"$['store']['book'][1]['author']"
"$['store']['book'][2]['author']"
"$['store']['book'][3]['author']"

但是,我想要点符号的输出

$.store.book[0].title
$.store.book[1].title
$.store.book[2].title
$.store.book[3].title

我无法在点符号中提取JsonPath。

java json jsonpath
© www.soinside.com 2019 - 2024. All rights reserved.