Open kaqqao opened 7 years ago
After looking deeper into Gson, this seems somewhat impractical to do. Still, I made a crude deserializer that implements this behavior: http://stackoverflow.com/questions/43294694/how-to-implement-a-gson-equivalent-of-jsonunwrap/43300684#43300684 Feel free to close this issue if you are not interested into going down this rabbit hole.
Is it possible to implement a feature similar to Jackson's
@JsonUnwrap
that would automatically wrap/unwrap a Json field (potentially unwrapping its field(s) further)?Example of the desired behavior:
This would then allow a flat Json structure such as:
to be (de)serialized to/from a
Business
object.Ideally, the strategy for deciding what to unwrap would be configurable so that annotations (as used above) are only one option, so that editing the beans isn't necessary. Going even further, supporting custom prefixing/suffixing to avoid name collision (see how I had to call fields
businessName
andfullName
instead of justname
) like@JsonUnwrap
does would be absolute perfection.Do you think this is feasible?