Advertisement
Guest User

Untitled

a guest
May 5th, 2016
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. //Using jayway/JsonPath for validating JSON in MockMvc
  2. Configuration conf = Configuration.builder()
  3. .options(Option.AS_PATH_LIST).build();
  4.  
  5.  
  6. MvcResult result = mockMvc.perform(get("<api-endpoint>"))
  7. .andExpect(status().isOk())
  8. //.andExpect(jsonPath("$[0]['property']").value(is(0)))
  9. .andReturn();
  10.  
  11. List<String> pathList = JsonPath.using(conf).parse(result.getResponse().getContentAsString()).read("$..*");
  12.  
  13. //This pathList will be a list of string for all available JsonPath values "$[0]['property']"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement