Guest User

Untitled

a guest
Feb 22nd, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. JSONObject jsonObject = new JSONObject(response);
  2. JSONArray array = jsonObject.getJSONArray("results");
  3. for (int i = 0; i<array.length();i++)
  4. {
  5. //get the photo reference from json of google place web api
  6. JSONObject o = array.getJSONObject(i);
  7. Places item = new Places();
  8.  
  9. JSONArray photo = o.getJSONArray("photos");
  10. JSONObject photos = photo.getJSONObject(0);
  11. String ph_ref = photos.getString("photo_reference");
  12.  
  13.  
  14. String id = o.getString("id");
  15. String name = o.getString("name");
  16. if (o.has("rating")) {
  17. String rat = o.getString("rating");
  18. item.setRating(rat);
  19. }else{
  20. item.setRating("0");
  21. }
  22.  
  23. org.json.JSONException: No value for photos
  24. at org.json.JSONObject.get(JSONObject.java:389)
  25. at org.json.JSONObject.getJSONArray(JSONObject.java:584)
Add Comment
Please, Sign In to add comment