android - How to parse "Weekday_text" array from Google Place API -
i have json array coming here: https://maps.googleapis.com/maps/api/place/details/json?placeid=chijovsfhourrjsrbhbndfi7rys&key=aizasyd_ka7xtnyffqnlykvkvgk5znqgqtzfztk
and parsing this, won't work. want 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"); (int = 0; < 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); }
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 = 0; < weekdayarray.length; i++) { // extract values here } } } }
Comments
Post a Comment