I have a class that I serialize / deserialize from / to JSON, XML using Jackson.
public class User {
Integer userId;
String name;
Integer groupId;
...
}
I want to ignore groupId when processing xml, so my XML will not include it:
<User>
<userId>...</userId>
<name>...</name>
</User>
But JSONs will be:
{
"userId":"...",
"name":"...",
"groupId":"..."
}
I know that @JsonIgnore will work in both, but I want to ignore it only in xml.
I know about mixing annotations that can be used to do this ( https://stackoverflow.com/a/164778/ ), but I think there should be a simple annotation that does this, but cannot find it. Jackson's documentation (at least for me) is not as good as I would have liked when trying to find such things.