I have a third party domain object that I wish to serialize to JSON using Jackson. There are a lot of properties on this accessible via public getters, but I am only interested in a very small subset of these. Since this is a third party object, I went with the mixin route. However, I couldn't find a good way to exclude everything from the original class other than the ones defined on the mixin interface. I tried to specify the @JsonIgnoreProperties on the mixin class, but it quickly gets out of hand with large number of properties to ignore. Any workarounds?
Thanks in advance!
EDIT: Adding some code
public class SpecialObject {
private String name;
private Integer id;
public String getName() {
return name;
}
public Integer getId() {
return id;
}
public String getFoo() {
return "foo";
}
}
public interface SpecialObjectMixin {
@JsonProperty
String getName();
}
I was hoping that I will only get name in the serialized JSON. BTW, I am using this for restful calls via cxf-jaxrs with Jackson as the provider.