Reputation: 75
i have one problem with my feed..
Sometimes is:
"logo": {
"logo": "56ab76c2d98028.97224188_logo.png",
"logo_thumbnail": "56ab76c2d98028.97224188_logo_thumbnail.png"
}
And sometime is:
"logo": false
My retrofit object is:
public class EventsItem
{
public LogoObject logo = new LogoObject();
}
And LogoObject is:
public class LogoObject {
private String logo;
private String logo_thumbnail;
public String getLogo()
{
return (!Helper.isStringEmpty(logo)) ? logo : logo_thumbnail;
}
}
If logo is false then retrofit says error
Expected BEGIN_OBJECT but was BOOLEAN at line 1 column 51 path $.logo
Thanks for answers..
Upvotes: 1
Views: 657
Reputation: 45500
You can use your own converter, or perhaps write a custom deserializer.
Look it up, here is an example:
http://www.javacreed.com/gson-deserialiser-example/
Or you can try to use Object
and check the type:
if (obj instanceof Boolean)
Upvotes: 2