Im trying to serialize a property based on the view. Unfortunately the code below doesn't work as Jackson reports a conflicting getter propperty "userId". Is there any way to get an object according to the view in an specific representation?
@JsonView(Views.Mongo.class)
@JsonProperty("userId")
public ObjectId getUserId() {
return userId;
}
@JsonView(Views.Frontend.class)
@JsonProperty("userId")
public String getUserIdAsString() {
return userId.toString();
}
This is what I want:
View 1:
{ userId: { '$oid' : "16418256815618" } }
View 2:
{ userId: "16418256815618" }