0

I am trying to deserialize a json response with the gson lib, the problem is that one json field can be a string or an object.

 "artist": "57eaef170e8784aa285d7009"

or

 "artist": {
  "_id": "57eaef170e8784aa285d7009",
  "name": "red hot chili peppers"
}

I don't know how to check wether it's a String or an Object and how to deserialize it properly in my model.

Aseith
  • 1
  • 4
  • Parse it manually without using GSON. – K Neeraj Lal Oct 05 '16 at 12:54
  • Can you be more specific? how can you do without it ? – Aseith Oct 05 '16 at 12:57
  • The accepted answer on the above link says to create an array to check for an exception, but you may be able to check by the "artist" length() and take it from there rather than depending on an exception. I never tried it myself but it may work. – Tasos Oct 05 '16 at 13:01

0 Answers0