I am using GSON parser to parse Http Response with JSON format as:
{ "type" : "A1", "payload": <Format as per type A1> }
{ "type" : "A2", "payload": <Format as per type A2> }
.
.
.
I don't have control over JSON output as I am writting only http client
I have defined base class as:
class Base {
String type;
Object payload;
}
Gson g = new Gson();
Base baseObj = gson.fromJson(response, Base.class);
// Need to cast and access baseObj.payload to specific class
But now I want to cast "Object payload" to specific class and access its member variables