简体   繁体   中英

Json filter data on the sibling node

I am new with JSONPath and any help is appreciated. I am trying to filter data based on its sibling value.

My JSON sample:

[

  {
  "id": "10300",
  "name": "NAME1"
  },
  {
  "id": "10500",
  "name": "NAME2"
  }
 ]

And I would like to query id by the name. I tried something like this, but without luck:

$..id[?(@name=='NAME1')]

I am sure I missed something trivial.

毕竟我自己找到了解决方案。

$..[?(@.name == 'NAME1')].id

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM