Skip to content

Add serialization support for @JsonUnwrapped with ObjectNode #3196

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

Closed
cowtowncoder opened this issue Jul 3, 2021 · 2 comments
Closed

Add serialization support for @JsonUnwrapped with ObjectNode #3196

cowtowncoder opened this issue Jul 3, 2021 · 2 comments

Comments

@cowtowncoder
Copy link
Member

cowtowncoder commented Jul 3, 2021

Currently @JsonUnwrapped has no effect on ObjectNode (or JsonNode) valued property.
Although in general JsonNode is to be handled as-is, with minimal changes (unlike POJOs), this seems like one case where property-annotation would sometimes make sense.

Specifically, it'd be great to allow sort "any-getter" alternative, where entries of an ObjectNode were written as if they were the properties to include without wrapper. Something like, say,

public class Root {
   @JsonUnwrapped
   public ObjectNode values; // having values of: { "a" : 1, "b" : 3 }
}

would get serialized as

{"a":1,"b":3}

instead of what happens currently

{  "values":{"a":1, "b":3}}

NOTE: this issue is specifically for allowing serialization -- supporting deserialization side would have separate challenges.

@cowtowncoder cowtowncoder changed the title Add some support for @JsonUnwrapped with ObjectNode Add serialization support for @JsonUnwrapped with ObjectNode Jul 3, 2021
@cowtowncoder
Copy link
Member Author

Note: the specific immediate challenge here is that instead of there being special JsonNodeSerializer (or subtypes), JsonNode implements JsonSerializable so actual classes include serialization logic and there is just SerializableSerialiazer thin wrapping layer.

Given this, it'd probably be necessary to change things slightly to, perhaps:

  1. Create specific SerializableSerializer alternative for JsonNode types, to handle JsonSerializer.unwrappingSerializer() call
  2. Figure out how to dynamically deal with requests to "unwrap"

@cowtowncoder cowtowncoder added most-wanted Tag to indicate that there is heavy user +1'ing action 2.15 and removed 2.13 labels Jan 26, 2023
@cowtowncoder
Copy link
Member Author

cowtowncoder commented Jan 26, 2023

Quick note: alternatively we could consider allowing ObjectNode (or JsonNode) to be used with @JsonAnyGetter.
This might be a better way to go, given that #3394 (include in 2.14) allows use with @JsonAnySetter.

Actually... given there is already #3604 requesting just that, I will close this issue as "won't fix".

@cowtowncoder cowtowncoder removed most-wanted Tag to indicate that there is heavy user +1'ing action 2.15 labels Jan 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant