Should GSON ignore varying types if they're not used in a class?
- by loeschg
I'm making an API call that returns JSON which has a particular field which either returns false or a map depending on content. It's a field that I don't care about. I expected GSON to ignore this particular field, though it doesn't seem to be. The object generation fails with the following message:
com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected a string but was BEGIN_OBJECT at line 1 column 403560
I've seen this particular question (Gson deserialize json with varying value types). I want to make sure I need to make a custom deserializer before doing so. I'm wondering if I may have another issue.
edit:
Example:
"anonymous_flag": { }
vs
"anonymous_flag": "yes"
Another Edit:
I actually had the field in my model object... I was referencing the wrong class. Judge away :)