List of usage examples for org.springframework.data.rest.webmvc.json.patch JsonPatchPatchConverter JsonPatchPatchConverter
JsonPatchPatchConverter
From source file:org.springframework.data.rest.webmvc.config.JsonPatchHandler.java
/** * Returns all {@link JsonPatchOperation}s to be applied. * /*from w w w . j a v a2s . c om*/ * @param source must not be {@literal null}. * @return * @throws HttpMessageNotReadableException in case the payload can't be read. */ private Patch getPatchOperations(InputStream source) { try { return new JsonPatchPatchConverter().convert(mapper.readTree(source)); } catch (Exception o_O) { throw new HttpMessageNotReadableException( String.format("Could not read PATCH operations! Expected %s!", RestMediaTypes.JSON_PATCH_JSON), o_O); } }
From source file:org.springframework.data.rest.webmvc.json.patch.JsonPatchTest.java
private Patch readJsonPatch(String jsonPatchFile) throws IOException, JsonParseException, JsonMappingException { ClassPathResource resource = new ClassPathResource(jsonPatchFile, getClass()); ObjectMapper mapper = new ObjectMapper(); JsonNode node = mapper.readValue(resource.getInputStream(), JsonNode.class); Patch patch = new JsonPatchPatchConverter().convert(node); return patch; }