I have a json response looks like below
{
“id”: 1,
“name”: “Karen”,
“phone”: “Samsung”
}
and a Java class like
public class Person {
public int id;
public Name name;
public Phone phone;
}
private class Name {
public String value;
}
private class Phone {
public String brand;
}
As you will see that unlike normal way by defining the name
and phone
as String, currently they were defined as a class with only one field, and it is not able to change the structure. Is there any way to use some Json annotation on class level to map the Json value to be its property, something like @JsonProperty(Name.class, "value")
?