Skip to content Skip to sidebar Skip to footer

Parsing JSON Array That Contain Objects With Different Attributes With Retrofit

how can I parse JSON array that contains JSON objects without names and each object have his own attributes in Android with Retrofit2. Json is something like this: [ { 'userna

Solution 1:

To parse that response you need the following class

  public class MainResponse{
    String username;
    int age;
    boolean active;
    String languages;
    String occupation;
    String phone_num;
    String email;
}

And your getData method

Call<List<MainResponse>> getData();

Post a Comment for "Parsing JSON Array That Contain Objects With Different Attributes With Retrofit"