Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add delegating serializers for JsonPatch and JsonMergePatch #28

Closed
mattnelson opened this issue Nov 29, 2022 · 2 comments
Closed

Add delegating serializers for JsonPatch and JsonMergePatch #28

mattnelson opened this issue Nov 29, 2022 · 2 comments
Labels
2.14 Intended for version 2.14.x jsr-353 Issue related to JSR-353/JSONP datatype module
Milestone

Comments

@mattnelson
Copy link

To simplify the serialization of json-p patch objects, proposing adding delegating serializers for JsonPatch>JsonArray and JsonMergePatch>JsonValue

It takes extra steps to convert a patch into a type that has a serializer available.

        addSerializer(JsonPatch.class, new StdDelegatingSerializer(new Converter<JsonPatch, JsonArray>() {
            @Override
            public JsonArray convert(JsonPatch value) {
                return value.toJsonArray();
            }
            @Override
            public JavaType getInputType(TypeFactory typeFactory) {
                return typeFactory.constructFromCanonical(JsonPatch.class.getName());
            }
            @Override
            public JavaType getOutputType(TypeFactory typeFactory) {
                return typeFactory.constructFromCanonical(JsonArray.class.getName());
            }
        }));
@cowtowncoder cowtowncoder added the jsr-353 Issue related to JSR-353/JSONP datatype module label Nov 30, 2022
@cowtowncoder
Copy link
Member

Sounds good to me.
Since this does not require changes to API, could even go in 2.14(.2) patch.

@cowtowncoder cowtowncoder added the 2.14 Intended for version 2.14.x label Nov 30, 2022
@cowtowncoder cowtowncoder changed the title Add delegating serializers for JsonPatch and JsonMergePatch Add delegating serializers for JsonPatch and JsonMergePatch Nov 30, 2022
@cowtowncoder cowtowncoder added this to the 2.14.2 milestone Nov 30, 2022
@cowtowncoder
Copy link
Member

Implemented as suggested; will be included in 2.14.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2.14 Intended for version 2.14.x jsr-353 Issue related to JSR-353/JSONP datatype module
Projects
None yet
Development

No branches or pull requests

2 participants