RFC 6902 implementation with GSON

670 views
Skip to first unread message

Frank Seidinger

unread,
Nov 2, 2014, 4:52:02 AM11/2/14
to googl...@googlegroups.com
Hi there,

I would like to know if there is any way to parse RFC 9602 compliant JSON patch documents and apply the patch to either another JSON document or a deserialized object using GSON.

In pseudo code this would look something like:

GsonBuilder gsonPatchBuilder = new GsonBuilder();
Gson gsonPatchParser = gsonPatchBuilder.create();
JsonPatch patch = gsonPatchParser.fromJson(jsonPatchString);

GsonBuilder gsonBuilder = new GsonBuilder();
gsonBuilder.applyPatch(patch);
Gson gsonParser = gsonBuilder.create();
MyObject myObject = gsonParser.fromJson(jsonString);

Resulting in a MyObject class patched by the RFC 9602 patch document.

I've seen so far only solutions for Jackson but non for GSON.

Kind regards,

Frank.

Jesse Wilson

unread,
Nov 2, 2014, 6:22:22 PM11/2/14
to googl...@googlegroups.com
Gson currently lacks support for RFC 6901 (patch) and RFC 6902. Building these on top of Gson's tree API should be straightforward.

Anton Tananaev

unread,
Nov 16, 2016, 7:29:37 PM11/16/16
to google-gson
You can use a third party library to create/apply JSON patches:

Reply all
Reply to author
Forward
0 new messages