Support indexing on arrays in body matching#339
Conversation
|
More of a curisotiy? @fbryden why a.b.0.c and not a.b[0].c |
|
@aimenebelfodil |
| @@ -162,7 +162,14 @@ fn matches_body(body_matcher: &BTreeMap<String, BodyMatcher>, body: &str) -> boo | |||
| let parts = path.split('.'); | |||
There was a problem hiding this comment.
@aimenebelfodil we currently split on . and treat each element as a way to traverse one layer deeper
| @@ -162,7 +162,14 @@ fn matches_body(body_matcher: &BTreeMap<String, BodyMatcher>, body: &str) -> boo | |||
| let parts = path.split('.'); | |||
There was a problem hiding this comment.
Would it be possible to treat arrays path differently than maps? For instance, would it be possible to follow the jsonpath syntax? It's the same syntax used in synthetics to validate the body response.
There was a problem hiding this comment.
@aimenebelfodil @vinckama I've implemented jsonpath-like accessing in 4393fa1
There was a problem hiding this comment.
Perfect, I did not see the comment at that time. Thanks for pushing this 🙇
There was a problem hiding this comment.
LGTM thanks
- Could you add a test where root is an array?
- Another test where we do have nested array
- And update the PR description too 🙇 with the latest updates
Thanks @fbryden 🥇
Indexing is currently not supported in the body matching path of config v2.
This adds support for it.
Allows two scenarios, where we attempt scenario 1, and fallback to scenario 2 in case we don't find a value at that path.
The query path is
a.b.0.c. Both scenarios will match.Scenario 1
Scenario 2