Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- JSONObject jsonObject = new JSONObject(response);
- JSONArray array = jsonObject.getJSONArray("results");
- for (int i = 0; i<array.length();i++)
- {
- //get the photo reference from json of google place web api
- JSONObject o = array.getJSONObject(i);
- Places item = new Places();
- JSONArray photo = o.getJSONArray("photos");
- JSONObject photos = photo.getJSONObject(0);
- String ph_ref = photos.getString("photo_reference");
- String id = o.getString("id");
- String name = o.getString("name");
- if (o.has("rating")) {
- String rat = o.getString("rating");
- item.setRating(rat);
- }else{
- item.setRating("0");
- }
- org.json.JSONException: No value for photos
- at org.json.JSONObject.get(JSONObject.java:389)
- at org.json.JSONObject.getJSONArray(JSONObject.java:584)
Add Comment
Please, Sign In to add comment