I am trying to create an entity like this
@Entity
public class Person extends Model {
@Id
public int id;
public String name;
}
However when I do toJson(person), my result contains both the fields id
and name
. But I don't want the id
to be shown.
Is there any annotation or something (like gson's Expose, for example) which will make toJson skip some fields so that the final json output does not contain the id
field??
[Short Answer] - Use @JsonIgnore (com.fasterxml.jackson.annotation.JsonIgnore)