sileht / python-jsonpath-rw-ext

Extensions for JSONPath RW
Apache License 2.0
59 stars 19 forks source link

match first level field #9

Closed gdamjan closed 7 years ago

gdamjan commented 8 years ago

Given the json:

{
  'type': 'message',
  'text': 'something'
}

how do I match the whole document, if 'type' == 'message' ?

I tried and failed with:

$[?(type == "message")]
$[?(@.type == "message")]
even
$[?(@.type)]
$[?(type)]
sileht commented 7 years ago

Search works on array object, the input should be:

[ 
  {
    'type': 'message',
    'text': 'something'
  },
  {
    'type': 'notmessage',
    'text': 'something'
  }
]

And then $[?(type == "message")]will work