Adilmo
Adilmo

Reputation: 117

gson deserialize List<Object>

I am trying to deserialize a rest service response which is something like this

Class ResponsePayload {

String status;
String errorDescription;

List<Object> responseDetails;

...
}

ResponsePayload gets parsed and under responseDetails I have a linked hashmap of the object which was sent.

On ResponsePayload, I have to again parse the object out of responseDetails.

I know beforehand the type of object which is going to be present in List.

What is the efficient and convenient way of doing this parsing in one go?

Is there a way to setup a deserializer to parse List into a type object.

Upvotes: 0

Views: 361

Answers (1)

Rajesh.k
Rajesh.k

Reputation: 2437

Retrofit automatically deserialize response to Your object type.what you have to do is jut specify the object type in response class like below

Class ResponsePayload {

String status;
String errorDescription;

List<ResponseDetails> responseDetails;

...
}

Upvotes: 1

Related Questions