Skip to content
Advertisement

Tag: jsonpath

Junit test with jsonPath doesn’t find the matching content

I have this simple unit test:- .andDo(MockMvcResultHandlers.print()); prints out this:- I can see there is “city”:”espoo”. How do I match this. I tired:- It give error:- DEBUG org.springframework.test.web.servlet.TestDispatcherServlet – Completed 200 OK DEBUG com.jayway.jsonpath.internal.path.CompiledPath – Evaluating path: $.size() DEBUG com.jayway.jsonpath.internal.path.CompiledPath – Evaluating path: $[‘city’] java.lang.AssertionError: No value at JSON path “$.city” Answer The response is of type Array: Therefore you

JSONPath resolver for Java objects

How can I get a value from an Java object instead from a JSON string by applying a JSONPath expression? I receive a Java object that is created from a JSON string (via Jackson, no way to influence it): I further have some JSONPath expressions as Java Strings reflecting values in the object (they might be much more complex): I

Advertisement