Nested JSON object parsing using GSON
<p>I have a nested JSON object like </p>

<pre><code>{
  "hours": {
    "Friday": {
      "close": "21:00",
      "open": "11:00"
    },
    "Tuesday": {
      "close": "21:00",
      "open": "11:00"
    }
  },
  "open": true,
  "categories": [
    "Fast Food",
    "Restaurants"
  ],
  "city": "Dravosburg",
  "review_count": 7,
  "name": "Mr Hoagie",
  "neighborhoods": [

  ],
  "longitude": -79.9007057,
  "state": "PA",
  "stars": 3.5,
  "latitude": 40.3543266,
  "attributes": {
    "Take-out": true,
    "Drive-Thru": false,
    "Good For": {
      "dessert": false,
      "latenight": false
    },
    "Caters": false,
    "Noise Level": "average",
    "Takes Reservations": false,
    "Delivery": false,
    "Ambience": {
      "romantic": false,
      "intimate": false,
      "classy": false
    },
    "Parking": {
      "garage": false,
      "street": false
    },
    "Has TV": false,
    "Outdoor Seating": false,
    "Attire": "casual"
  },
  "type": "business"
}
</code></pre>

<p>I am using GSON to parse this json object. I have created POJO classes as below:</p>

<pre><code> public class BusinessPojo {

   private String type;
   private String name;
   private ArrayList&lt;String&gt; neighborhoods = new ArrayList&lt;&gt;();
   private ArrayList&lt;String&gt; categories = new ArrayList&lt;&gt;();
   private BusinessDay hours = new BusinessDay();
   private String city;
   private boolean open;
   private String state;
   private double latitude;
   private double longitude;
   private float stars;
   private int review_count;
   private BusinessAttributes attributes;
//getters and setters
}
public class BusinessDay {
    private BusinessHourTime monday = new BusinessHourTime();
    private BusinessHourTime tueday = new BusinessHourTime();
    private BusinessHourTime wednesday = new BusinessHourTime();
    private BusinessHourTime thursday = new BusinessHourTime();
    private BusinessHourTime friday = new BusinessHourTime();
    private BusinessHourTime satday = new BusinessHourTime();
    private BusinessHourTime sunday = new BusinessHourTime();
// getters and setters
}
public class BusinessHourTime {
    private String open;
    private String close;
//getters and setters
}
</code></pre>

<p>and similarly for <code>Attributes</code>, inside Attributes for <code>Parking</code>, <code>Ambience</code> and <code>GoodFor</code>. This is my code:</p>

<pre><code>String line = "json object"
Gson g = new Gson();
BusinessPojo businessJsonObj = g.fromJson(line, BusinessPojo.class);
</code></pre>

<p>When I try to access <code>"Drive-Thru"</code> like </p>

<pre><code>System.out.println(businessJsonObj.getAttributes().isDriveThru());
</code></pre>

<p>I get value <code>false</code>, however when I try to access  <code>open</code> from <code>Friday</code> or <code>Tuesday</code> I get <code>null</code> like         </p>

<pre><code>System.out.println(businessJsonObj.getHours().getTuesday().getOpen());
</code></pre>

<p>Could anyone help me understand what mistake have I done in my code?</p>