Package com.github.fge.jsonpatch

Examples of com.github.fge.jsonpatch.JsonPatch.apply()


        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()));
View Full Code Here


        for (JsonNode operation : patch) {
            try {
                final ArrayNode nodes = JsonNodeFactory.instance.arrayNode();
                nodes.add(operation);
                JsonPatch patchOperation = JsonPatch.fromJson(nodes);
                jsonNode = patchOperation.apply(jsonNode);
            } catch (JsonPatchException e) {
                logger.log(Level.FINEST, "ignore field not found");
            }
        }
        return jsonNode;
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.