Open ghost opened 7 years ago
Firstly, jsonPathMatch
doesn't work probably if the JSON node in the query is a root attribute. This is a known issue.
Another thing is that your example is using jsonMatch
, not jsonPathMatch
Do we have any plan to fix this known issue?
Any news on this ?
Quickly looking at this, this looks like a duplicate issue of #636.
I don't think the Go JsonPath library that hoverfly uses (https://github.com/NodePrime/jsonpath) supports root level filtering, for example: https://stackoverflow.com/questions/25031187/jsonpath-selecting-root-level-field-if-satisfies-a-condition
It could be a problem for some users, and I will also raise this issue with that project.
Thanks for the quick reply.
The https://github.com/NodePrime/jsonpath project looks abandoned to me, so I don't think that raising an issue with that project will help.
Have you got any better suggestions @maxtepkeev ?
At least 2 come to mind:
1) Try to find another active project that implements jsonpath or if there's none 2) Make a fork of the NodePrime/jsonpath, fix the bug there, make PR which will hopefully be merged someday. Until it's not merged vendor this fork.
We have tried several jsonpath libraries for Golang and none of them does all the jsonpath magics. Also NodePrime/jsonpath is deprecated, hoverfly is now using this jsonpath package: https://github.com/kubernetes/client-go/blob/master/util/jsonpath
There will be a workaround once the matcher chaining feature is implemeted: https://github.com/SpectoLabs/hoverfly/issues/761
Partial matching of request using jsonPath match is not working when I am trying to match the root element. For example: "body":{\",\t\"stockNumber\": \"AA323IK\",\t\"count\": \"324\"}"
}
As per TommySitu
Tommy Situ @tommysitu Jun 22 10:26
@subham1112, the standard JSONPath expression to achieve what you need is "$[?(@.itemId == 123456)]”
Unfortunatly the JSONPath go library we are using doesn’t work properly if the JSON node in the query is a root attibute.
"jsonMatch":"{\t\"itemId\": \”
Please help.