com.github.fge.jsonpatch.StandardJsonPatchFactory Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of json-patch-box-metadata Show documentation
Show all versions of json-patch-box-metadata Show documentation
JSON Patch (RFC 6902) and JSON Merge Patch (RFC 7386) implementation in Java
The newest version!
package com.github.fge.jsonpatch;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectReader;
import com.fasterxml.jackson.databind.ObjectWriter;
import com.fasterxml.jackson.databind.jsontype.NamedType;
import com.github.fge.jackson.JacksonUtils;
import com.github.fge.jsonpatch.operation.*;
import com.github.fge.msgsimple.bundle.MessageBundle;
import com.github.fge.msgsimple.load.MessageBundles;
import java.io.IOException;
/**
* StandardJsonPatchfactory can create a JsonPatchFactory configured to work with the RFC6902 set of JSON Patch operations.
*/
public class StandardJsonPatchFactory
{
public static JsonPatchFactory create()
{
ObjectMapper mapper = JacksonUtils.newMapper();
mapper.registerSubtypes(
new NamedType(AddOperation.class, AddOperation.OPERATION_NAME),
new NamedType(CopyOperation.class, CopyOperation.OPERATION_NAME),
new NamedType(MoveOperation.class, MoveOperation.OPERATION_NAME),
new NamedType(RemoveOperation.class, RemoveOperation.OPERATION_NAME),
new NamedType(ReplaceOperation.class, ReplaceOperation.OPERATION_NAME),
new NamedType(TestOperation.class, TestOperation.OPERATION_NAME)
);
return new JsonPatchFactory(mapper);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy