So through research on Stackoverflow, especially this topic, I've determined that I have a JSON object dictionary embedded in an otherwise working getter/setter setup. When I make a call to the API, the traditional getter/setters for the properties work well, but that's because I know what the names of the properties are. How can I get this working for unknown properties of an object called errors
, and what format is this object in (Map<String,List>
)?
API Response:
{
"success":false,
"response_code":1,
"status_message":"One or more errors has occurred.",
"errors":{
"171":["Some error message."],
"555":["Some other error message."]
}
}
My POJO:
public class APIResponse {
private boolean success;
private int response_code;
private String status_message;
private Map<String, List> errors = new HashMap<>();
...
}
How can I set the getter/setters and the correct dictionary format (Looks like maybe it's Map<String,List>
) so that I can start receiving this dynamic errors
object?
I'm using an Invocation.Builder
to parse out the API response into an object.
Response response= invocationBuilder.post(Entity.entity(APIRequest, MediaType.APPLICATION_JSON));
APIResponse formattedResponse = response.readEntity(APIResponse.class);