use of com.jayway.jsonpath.spi.json.GsonJsonProvider in project JsonPath by jayway.
the class IssuesTest method issue_97.
@Test
public void issue_97() throws Exception {
String json = "{ \"books\": [ " + "{ \"category\": \"fiction\" }, " + "{ \"category\": \"reference\" }, " + "{ \"category\": \"fiction\" }, " + "{ \"category\": \"fiction\" }, " + "{ \"category\": \"reference\" }, " + "{ \"category\": \"fiction\" }, " + "{ \"category\": \"reference\" }, " + "{ \"category\": \"reference\" }, " + "{ \"category\": \"reference\" }, " + "{ \"category\": \"reference\" }, " + "{ \"category\": \"reference\" } ] }";
Configuration conf = Configuration.builder().jsonProvider(new GsonJsonProvider()).mappingProvider(new GsonMappingProvider()).build();
DocumentContext context = JsonPath.using(conf).parse(json);
context.delete("$.books[?(@.category == 'reference')]");
List<String> categories = context.read("$..category", List.class);
assertThat(categories).containsOnly("fiction");
}
Aggregations