// Use the Jackson 2.x classes to convert both the incoming patch
// and the current state of the object into a JsonNode / JsonPatch
ObjectMapper mapper = new ObjectMapper();
JsonNode serverState = mapper.readValue(baos.toByteArray(), JsonNode.class);
JsonNode patchAsNode = mapper.readValue(readerInterceptorContext.getInputStream(), JsonNode.class);
JsonPatch patch = JsonPatch.fromJson(patchAsNode);
try {
// Apply the patch
JsonNode result = patch.apply(serverState);
// Stream the result & modify the stream on the readerInterceptor
ByteArrayOutputStream resultAsByteArray = new ByteArrayOutputStream();
mapper.writeValue(resultAsByteArray, result);
readerInterceptorContext.setInputStream(new ByteArrayInputStream(resultAsByteArray.toByteArray()));