Open
Description
Sample JSON: Response from Github when getting a list of all issues
The response contains two objects, one with a pull_request
property and the other doesn't have a pull_request
property.
[
{
"id": 1,
"pull_request": {
"url": "https://api.github.com/repos/octocat/Hello-World/pulls/1347",
"html_url": "https://github.com/octocat/Hello-World/pull/1347",
"diff_url": "https://github.com/octocat/Hello-World/pull/1347.diff",
"patch_url": "https://github.com/octocat/Hello-World/pull/1347.patch"
},
"updated_at": "2011-04-22T13:33:48Z"
},
{
"id": 2,
"updated_at": "2011-04-22T13:33:48Z"
}
]
Bug
The request is to support this scenario
🔴 Failing scenario. Cannot negate a filter expression using
!
Intent:
Get all objects from sample json data that don't have a pull_request
property
Query
JsonPath.new('$[?([email protected]_request)]').on(json)
🐞 Actual Result:
[]
Expected Result
[
{
"id": 2,
"updated_at": "2011-04-22T13:33:48Z"
}
]
🟢 Passing scenario. This scenario is working fine and as intended.
Intent:
Get all objects from sample data with the pull_request
property in the response
Query
JsonPath.new('$[?(@.pull_request)]').on(json)
Result from JsonPath
[
{
'id' => 1,
'pull_request' => {
'url' => 'https://api.github.com/repos/octocat/Hello-World/pulls/1347',
'html_url' => 'https://github.com/octocat/Hello-World/pull/1347',
'diff_url' => 'https://github.com/octocat/Hello-World/pull/1347.diff',
'patch_url' => 'https://github.com/octocat/Hello-World/pull/1347.patch'
},
'updated_at' => '2011-04-22T13:33:48Z'
}
]
Metadata
Metadata
Assignees
Labels
No labels