在JsonPath中,我尝试从一个可用的json节点中挑选属性。然而,我想不出一个表达式。我试过使用anyOf,但没有成功。例如,我需要从任何一家商店(A或B)中取出书籍。我对从哪个商店买的书不感兴趣。请帮帮忙。
"storeA": {
"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
}
]
},
"storeB": {
"book": [
{
"category": "fiction",
"author": "Herman Melville",
"title": "Moby Dick",
"isbn": "0-553-21311-3",
"price": 8.99
},
{
"category": "action",
"author": "J. R. R. Tolkien",
"title": "The Lord of the Rings",
"isbn": "0-395-19395-8",
"price": 22.99
}
]
}
}```
发布于 2020-10-04 19:03:00
我想你在找通配符选择器。我不确定您的Java实现将如何具体做到这一点,但它的路径是$.*.book
...
通配符属性选择器.*
可以做到这一点。它将获取该对象的所有属性。
https://stackoverflow.com/questions/64106704
复制