LEE
LEE

Reputation: 3605

Retrofit example with a json response that include Json array and Json object, both?

I need an example for my android sample retrofit app that handles a single json response that includes both json array and json object data.

Any help would mean a lot to me :)

Here is the json response. I've used it from this link

{
availability: "0",
results: [
{

key1: 5,
key2: 16,
key3: "My key"
}

],
count: 15,
activitycount: "0"
}

Upvotes: 0

Views: 2092

Answers (1)

Nachi
Nachi

Reputation: 4248

Just use a List in your retrofit response object when you have to use JSON arrays.

So your model would look like this

public class ResponseObject {
    public String availability;
    public int count;
    public String activitycount;
    public List<Results> results;

    public class Results {
         public int key1;
         public int key2;
         public String key3;
    }
}

Upvotes: 4

Related Questions