I'd like to serialize, via Jackson, my Foo
interface:
public interface Foo { }
It has two instances: Standard and Debug responses. I'll only show the Standard
response as it adequately conveys my question.
public class FooRegular implements Foo {
private int number;
public FooRegular(final int number) { this.number = number; }
@JsonProperty("NUM")
public getNumber() {
return number;
}
}
Note that, I'm returning a Foo
in my Controller class:
public Response sendResponse() {
Foo foo = getFoo(); // returns FooRegular
return buildResponse(foo); // returns some Response with `foo` as its body
}
However, my response is:
{ number : 1234 }
I looked at this answer, which is what I've tried, but I'm not seeing the expected result.
How can I override the JSON response to have a key of NUM
rather than number
?