FasterXML / jackson-annotations

Core annotations (annotations that only depend on jackson-core) for Jackson data processor
https://github.com/FasterXML/jackson
Apache License 2.0
1.03k stars 330 forks source link

FEATURE:@JsonOnlyProperties / @JsonIncludeProperties needed #133

Closed sunphy closed 6 years ago

sunphy commented 6 years ago

Let's say you have 1 entity with cascade need to be serialized, when you only need serialize part of cascaded entity, you should do it as following:

class Organization{
    private int id;
    private String name;
    private String address;
    private String telehpone;
    private String website;
    ......
}
class Person{
    private int id;
    private String firstName;
    private String lastName;
    @JsonIgnoreProperties({"address","telephone","website"})
    private Organization organization;
}

but what if the ignored properties is too many and I only need the id and name properties to be serialized?A @JsonOnlyProperties or @JsonIncludeProperties is more convenient and very easy to use. Think this scenario is most needed.

cowtowncoder commented 6 years ago

I think this is already filed as:

https://github.com/FasterXML/jackson-databind/issues/1296

and the reason it sort of belongs more in jackson-databind is just because adding annotation is simple, but adding actual handling and support is anything but (due to complexity of processing, at this point).

sunphy commented 6 years ago

OK.Thank you. I think this is very useful!

cowtowncoder commented 6 years ago

Closing this in favor of the issue mentioned above.

sp4ce commented 4 years ago

Pull request: