My application is consuming a third party API which produces a JSON response. I have mapped relevant pojo classes to the respective JSON responses. But I have a difficulty with mapping a particular response which has a property "message" that is sometimes String and sometimes Object.
The datatype of the property "message" changes for particular requests for the same API call. I don't want to parse the JSON string using JSONObject or a JSONArray instead I want to map this response to a pojo class.
Can anybody please help me with this? Thanks!
Response 1
{
"Message": {
"name": "John Doe"
}
}
Response 2
{
"Message": "some error message"
}
I asked the API provider to change this behaviour but he/she refuses to my request saying he does not have control over what is produced in the json response.