The following response object results in the very same order in JSON format:
public SpecificResponse {
private int id;
private int processId;
}
{ "id": 1, "processId": 1 }
When this object inherits from ProcessResponse
having an extra field List<Message> messages
, this field suddenly comes as first in the JSON response:
{
"messages": [{
"code": "CODE1",
"Message": "Bla..."
}, {
"code": "CODE2",
"Message": "Ble..."
}],
"id": 1,
"processId": 1
}
I want to have messages
field (and others) as last. There is a way to push messages
to the end of the JSON using:
@JsonPropertyOrder({ "id", "processId", "messages"})
This solution becomes hell in case there are a lot of instance fields inherited. Is there another way explicitly specifying that the inherited fields come last for selected objects?