I have below JSON . At any point of time only one of the field "car" or "bike" can be null .Not both at the same time.How can I validate json using Jackson annotations. All the fields in JSON are mandatory
{
"name": "John",
"age": 30,
"car": "Toyota",
"bike": "Honda"
}
My Java Pojo Objects
public class Example
{
@JsonProperty("name")
public String name;
@JsonProperty("age")
public Integer age;
@JsonProperty("car")
public String car;
@JsonProperty("bike")
public String bike;