Skip to content

@JsonUnwrapped completeness: allow more flexible renaming #385

@jhhdk

Description

@jhhdk

Prefix and Suffix not sufficient for every use case.
While a very narrow use case consider following example:

class Rectangle {
   @JsonUnwrapped(prefix="topLeft")
   Point topLeft;

   @JsonUnwrapped(prefix="bottomRight")
   Point bottomRight;
}

For now this would be serialized as:
{
topLeft.x: 0,
topLeft.y: 0,
bottomRight.x: 2048.
bottomRight.y: 1080
}

From documentation it would seem its not possible to coerce Jackson into serializing it as:
{
left: 0,
top: 0,
right: 2048
bottom: 1080,
}

I am not entirely sure that this is even possible but I suppose something along the lines of:

class Rectangle {
   @JsonUnwrapped(
       names = {"x","y"},
       renames= {"left", "top"}
   )
   Point topLeft;

   @JsonUnwrapped(
       names = {"x","y"},
       renames= {"right", "bottom"}
   )
   Point bottomRight;
}

Would cover all thinkable use cases.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions