JSONPath表达式同时包含父元素和子元素

时间:2019-01-21 06:24:25

标签: jsonpath

给出:

{ "store": {
"Test": "Tester1",
"Test2": "Tester2",
"book": [ 
  { "category": "reference",
    "author": "Nigel",
    "title": "Sayings of the Century",
    "price": 8.95
  },
  { "category": "fiction",
    "author": "Evelyn Waugh",
    "title": "Sword",
    "price": 12.99
  }
],
"bicycle": {
  "color": "red",
  "price": 19.95
}

JSON路径-$ .store.book将仅返回子元素。

我想要的是将父书包含其子值:

  {
"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
  }
]
}

谢谢!

0 个答案:

没有答案