I have an API which returns a collection of JSON objects and I want to check their values. I can check that the values exist within the collection with:
jsonpath "$.books[*].title includes "Introduction to Algorithms"
jsonpath "$.books[*].author includes "Thomas H. Cormen"
but I can not confirm that the these values are within the same object.
Proposal
Allow the includes predicate to check for a object within a collection, i.e for the collection:
books: [
{
"title": "Introduction to Algorithms",
"author": "Thomas H. Cormen",
"publisher": "The MIT Press"
},
...
]
You can check with an object:
jsonpath "$.books includes
{
"title": "Introduction to Algorithms",
"author": "Thomas H. Cormen",
}
or one in a variable:
jsonpath "$.books includes {{myAwesomeBook}}
This would return true even if the object in the collection has additional keys. i.e. the above examples would return True.
Additional context and resources
There could be a keyword instead of the newline to invoke this behavior, possibly object?
Problem to solve
I have an API which returns a collection of JSON objects and I want to check their values. I can check that the values exist within the collection with:
but I can not confirm that the these values are within the same object.
Proposal
Allow the includes predicate to check for a object within a collection, i.e for the collection:
You can check with an object:
or one in a variable:
This would return true even if the object in the collection has additional keys. i.e. the above examples would return True.
Additional context and resources
object
?