-
Notifications
You must be signed in to change notification settings - Fork 528
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to assert if a json object is included in a collection #420
Comments
Hi @fjchen7, You're right, currently Note that you can for the time-being use the following jsonpath asserts in order to be more specific:
But I agree that yours would be more readable
|
Great. Thanks @fabricereix, your answer could meet most of my requirement. BTW, can I filter nested element? {
"fruit": [
{
"name": "apple",
"price": {
"US": 100,
"UN": 110
}
},
{
"name": "grape",
"price": {
"US": 200,
"UN": 150
}
}
]
} I tried with this
But it returns |
I don't think this is a valid jsonpath expression. You can always quickly check with http://jsonpath.com/. |
Great project and we are ready to use it for production test. Thanks for help! |
Sorry my mistake. I gave a wrong jsonpath expression in my last reply. Actually the expression However in
|
The original "spec" https://goessner.net/articles/JsonPath/ is still the one we refer to to, but it is not very detailed. We also add these extra features when they make sense and often they are also implemented in http://jsonpath.com. |
@fjchen7, the support for nested object has now been merged into master. |
Amazing. You guys are very productive. Very appreciate it! |
Assume that we have the json
How to assert that
{"name": "apple", "price": 100}
is in collection? For now what I can do is thatBut this is not the exact assertion I want. It checks these two values separately.
Seems that the keyword
includes
only supports literal value? Can we extend it to json object? Just likeThe text was updated successfully, but these errors were encountered: