I have a simple class:
@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "id", scope = Endpoint.class)
public class Endpoint {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@JsonView({View.Endpoint.class, View.User.class})
private Long id;
@NotNull
@NotEmpty(message = "Phone number is required.")
@JsonView({View.Endpoint.class, View.Call.class, View.User.class})
private String phoneNumber;
@JsonView({View.Endpoint.class, View.Call.class, View.User.class})
private String callerId;
@ManyToOne(optional = false)
@JsonView(View.Endpoint.class)
@ApiModelProperty(hidden = true)
private User user;
...
@Override
@JsonView({View.Endpoint.class, View.Call.class, View.User.class})
public String getUri() {
return EndpointController.BASE_PATH + "/" + getId();
}
}
I get the following error when trying to deserialize:
com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "uri" (class com.example.server.telephony.endpoint.Endpoint), not marked as ignorable (5 known properties: "id", "label", "callerId", "phoneNumber", "user"])
Since URI is a generated value there is no field to annotate with @JsonIgnore
. Any suggestions on what to do in this case?