I need to map a JSON string which includes values named long and short:
"status": {
"long": "Finished",
"short": "F",
"elapsed": 90
}
I tried the following class:
public class Status {
@JsonProperty("long")
public String _long;
@JsonProperty("short")
public String _short;
@JsonProperty("elapsed")
public Object elapsed;
}
with the command:
objectMapper.readValue(resBody, Response.class);
response contains the status part:
{
"response": {
"id": 157016,
"timezone": "UTC",
"date": "2019-08-10T11:30:00+00:00",
"timestamp": 1565436600,
"status": {
"long": "Long Value",
"short": "LV",
"elapsed": 20
}
}
}
But still I get the following error:
com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "long"
How can this be fixed? I do not have control on the JSON format.