title: How to parse a nested json object using Get request in retrofit?
body: <p>i want to make a simple app similar to Uber eats where you can order food and i would like to use the the json object below to get the data and bind it to my recyclerview using retrofit's get method.  this is the link for the raw json file : <a href="https://pastebin.com/raw/xGGjGVD9" rel="nofollow noreferrer">https://pastebin.com/raw/xGGjGVD9</a></p>
  
  <pre><code>{
  "categories": {
    "01": {
      "image": "http://web.archive.org/web/20160530195530if_/http://medifoods.my/wp-content/uploads/2015/03/cover-menu-fingerfoods2.jpg",
      "name": "Finger Foods"
  },
    "02": {
      "image": "http://web.archive.org/web/20160530200622if_/http://medifoods.my/wp-content/uploads/2015/03/cover-menu-westernsoup1.jpg",
      "name": "Western Soup"
  },
    "03": {
      "image": "http://web.archive.org/web/20160530163903if_/http://medifoods.my/wp-content/uploads/2015/03/cover-menu-easternsoup.jpg",
      "name": "Eastern Soup"
  },
    "04": {
      "image": "http://web.archive.org/web/20160530143505if_/http://medifoods.my/wp-content/uploads/2015/03/cover-menu-sandwich.jpg",
      "name": "Sandwich"
  },
    "05": {
      "image": "http://web.archive.org/web/20160531085702if_/http://medifoods.my/wp-content/uploads/2015/03/cover-menu-pizza.jpg",
      "name": "pizza"
  },
    "06": {
      "image": "http://web.archive.org/web/20160530202100if_/http://medifoods.my/wp-content/uploads/2015/03/cover-menu-pasta1.jpg",
      "name": "pasta"
  },
    "07": {
      "image": "http://web.archive.org/web/20160530202109if_/http://medifoods.my/wp-content/uploads/2015/03/cover-menu-chicken.jpg",
      "name": "Chicken"
  },
    "08": {
      "image": "http://web.archive.org/web/20160531085955if_/http://medifoods.my/wp-content/uploads/2015/03/cover-menu-fish.jpg",
      "name": "Fish"
  },
    "09": {
      "image": "http://web.archive.org/web/20160531025351if_/http://medifoods.my/wp-content/uploads/2015/03/cover-menu-vegetarian.jpg",
      "name": "Chinese Vegetarian"
  },
    "10": {
      "image": "http://web.archive.org/web/20160530195451if_/http://medifoods.my/wp-content/uploads/2015/03/cover-menu-delights.jpg",
      "name": "Medifoods Delights"
  },
    "11": {
      "image": "http://web.archive.org/web/20160531054218if_/http://medifoods.my/wp-content/uploads/2015/03/cover-menu-snacks.jpg",
      "name": "Snacks"
     }
   }
  }
  </code></pre>
  
  <p><strong>What i have done so far :</strong> 
  i have made 3 classes to fetch the data from the first object with the number "01" but that is just one object i have 9 more objects and if i make a new class for each and every object i will have a lot of classes. is there a better way to parse this json object or i have to make a new class for each object. </p>
  
  <pre><code>public class Properties {
  
  @SerializedName("categories")
  private Categories categories;
  
  public Properties(Categories categories) {
      this.categories = categories;
  }
  
  public Categories getCategories() {
      return categories;
  }
  </code></pre>
  
  <p>second class : </p>
  
  <pre><code>public class Categories {
  
  @SerializedName("01")
  private Foods foods;
  
  public Categories(Foods foods) {
      this.foods = foods;
  }
  
  public Foods getFoods() {
      return foods;
  }
  </code></pre>
  
  <p>third class : </p>
  
  <pre><code>public class Foods {
  
  private String image;
  private String name;
  
  public Foods(String image, String name) {
      this.image = image;
      this.name = name;
  }
  
  public String getImage() {
      return image;
  }
  
  public String getName() {
      return name;
  }
  </code></pre>
  
  <p>MainActivivy : </p>
  
  <pre><code>private void getFoodProperties() {
      Call&lt;Properties&gt; getFood = foodAPI.getProperties();
      getFood.enqueue(new Callback&lt;Properties&gt;() {
          @Override
          public void onResponse(Call&lt;Properties&gt; call, Response&lt;Properties&gt; response) {
              if (!(response.isSuccessful())) {
                  Log.d(TAG, "onResponse: "+ response.code());
                  return;
              }
  
              Log.d(TAG, "onResponse: " + response.body());
              foods.add(response.body());
  
              String name = foods.get(0).getCategories().getFoods().getName();
              String image = foods.get(0).getCategories().getFoods().getImage();
              Log.d(TAG, "onResponse: " + name + "  " + image);
  
          }
  </code></pre>
  
  <p>Api interface : </p>
  
  <pre><code>public interface FoodApi {
  
  @GET("xGGjGVD9")
  Call&lt;Properties&gt; getProperties();
  </code></pre>
  
  <p>}</p>