public String removeJSONPathElement ( String jsonString , String expr ) { Configuration conf = Configuration . builder ( ) . jsonProvider ( new GsonJsonProvider ( ) ) . mappingProvider ( new GsonMappingProvider ( ) ) . build ( ) ; DocumentContext context = JsonPath . using ( conf ) . parse ( jsonString ) ; context . delete ( expr ) ; return context . jsonString ( ) ; }
Remove a subelement in a JsonPath