Stack Exchange
How to parse "Weekday_text" array from Google Place API
I have my json array coming from here:
https://maps.googleapis.com/maps/api/place/details/json?placeid=ChIJOVsFHOURrjsRBhBNDfi7Rys&key=AIzaSyD_kA7xtNYffQNlykVkVGk5ZNQgQtZFZTk
and I am parsing like this, but it won't work.  I want to parse "weekday_text":
if (status == 200) {
   HttpEntity entity = response.getEntity();
   String data = EntityUtils.toString(entity);
   JSONObject json = new JSONObject(data);
   JSONArray jarraydes = json.getJSONArray("result");    
   for (int i = 0; i < jarraydes.length(); i++) {
      JSONObject object = jarraydes.getJSONObject(i);    
      Elements parameters = new Elements();    
      JSONObject objecttwo = object.getJSONObject("opening_hours");                            
      parameters.setOpeninghours(objecttwo.getString("weekday_text"));    
      Log.d("Openhours", "Open : " + objecttwo.getString("open_now"));    
      Toast.makeText(getApplicationContext(), objecttwo.getString("open_now"), Toast.LENGTH_LONG).show();*/    
      elementList.add(parameters);    
}


Please don't disclose your confidential information (API_KEY) as it maybe misused

Try below:
JSONObject responseObject = new JSONObject(data);
JSONObject resultObject = responseObject.optJSONObject(“result”);
if(result != null) {
 JSONObject openingObject =  resultObject.optJSONObject(“opening_hours”);
 if(openingObject != null) {
   JSONArray weekDayArray = openingObject.optJSONArray(“weekday_text”);
    if(weekDayArray != null) {
     for(int i = 0; i < weekDayArray.length; i++) {
       // extract values here
    }
  }
 }
}

