Skip to content
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

Consider adding JsonPath support for JsonNode #152

Closed
vbsteven opened this issue Apr 2, 2019 · 2 comments
Closed

Consider adding JsonPath support for JsonNode #152

vbsteven opened this issue Apr 2, 2019 · 2 comments
Assignees

Comments

@vbsteven
Copy link
Contributor

@vbsteven vbsteven commented Apr 2, 2019

Currently when asserting deeply nested JSON documents you have to chain path() methods to get to the leaf nodes. This can become very noisy:

expectThat(jsonNode) {
    path("_links").path("self").path("href")
        .textValue().isEqualTo("http://xxx")
}

A potential solution for this could be to integrate the JsonPath library (based on Jackson) to get something like this:

expectThat(jsonNode) {
    jsonPath("$_links.self.href")
        .textValue().isEqualTo("http://xxx")
}

I might have time later this week to try out a PoC for this.

@robfletcher

This comment has been minimized.

Copy link
Owner

@robfletcher robfletcher commented Apr 3, 2019

Sounds good

@robfletcher robfletcher self-assigned this Dec 15, 2019
robfletcher added a commit that referenced this issue Dec 17, 2019
Relevant to #152
robfletcher added a commit that referenced this issue Dec 17, 2019
Relevant to #152
robfletcher added a commit that referenced this issue Dec 17, 2019
Relevant to #152
@robfletcher

This comment has been minimized.

Copy link
Owner

@robfletcher robfletcher commented Dec 18, 2019

Not JSON Path exactly but I've added at methods using Jackson's JSON Pointer support in 2355364. Your example above would be:

expectThat(jsonNode)
  .at("/_links/self/href")
  .textValue()
  .isEqualTo("http://xxx")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.