I have a result from a web service that returns either a boolean value or a singleton map, e.g.
Boolean result:
{ id: 24428, rated: false } <
I asked a similar question - JSON POJO consumer of polymorphic objects
You have to write your own deserialiser that gets a look-in during the deserialise process and decides what to do depending on the data.
deserialiser
There may be other easier methods but this method worked well for me.