I have a REST API response object class which contains various members and their getters and setters. one of the members is
private String name;
and it is JSON'ized fine to something like
"name": "John",
However, for some reason I want to change this member to be
private Name name;
where Name is
public class Name implements Something {
private String str;
public Name(String name) {
this.str = name;
}
@Override
public String toString() {
return str;
}
public String getValue() {
return str;
}
//... other methods
}
But now it is JSON'ized to something like
"name": {
"value": "John"
},
is there anyway i can annotate the name field so to use the toString() so its JSON representation still looks like below?
"name": "<name.toString()>"