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
Labels
🦄 enhancement New feature or request

Comments

@vbsteven
Copy link
Contributor

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
Copy link
Owner

Sounds good

@robfletcher robfletcher added the 🦄 enhancement New feature or request label Apr 3, 2019
@robfletcher robfletcher self-assigned this Dec 15, 2019
robfletcher added a commit that referenced this issue Dec 17, 2019
robfletcher added a commit that referenced this issue Dec 17, 2019
robfletcher added a commit that referenced this issue Dec 17, 2019
@robfletcher
Copy link
Owner

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
Labels
🦄 enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants