I want to get fullname including title, first and last and city value from the location in xml file. I mean correct path. Can you help with this code. Thank you.
JSONObject object = new JSONObject(s);
JSONArray array = object.optJSONArray("results");
for (int i = 0; i < array.length(); i++) {
JSONObject jsonObject = array.optJSONObject(i);
String Name = jsonObject.optString("name");
String City = jsonObject.optString("location");
String Email = jsonObject.optString("email");
String Phone = jsonObject.optString("phone");
testModel model = new testModel();
model.setFullname(Name);
model.setCity(City);
model.setEmail(Email);
model.setPhone(Phone);
arrayList.add(model);
JSON response:
{"results":[{"name":{"title":"Mrs","first":"Elsa","last":"Sanchez"},"location":{"street":{"number":8890,"name":"Rue Dumenge"},"city":"Pau","state":"Ardèche","country":"France","postcode":61036,"coordinates":{"latitude":"-3.4635","longitude":"168.2515"},"timezone":{"offset":"0:00","description":"Western Europe Time, London, Lisbon, Casablanca"}},"email":"elsa.sanchez@example.com","phone":"02-24-50-09-33","picture":{"large":"https://randomuser.me/api/portraits/women/39.jpg","medium":"https://randomuser.me/api/portraits/med/women/39.jpg","thumbnail":"https://randomuser.me/api/portraits/thumb/women/39.jpg"}}],"info":{"seed":"3060b5a6b7ff6a03","results":1,"page":1,"version":"1.3"}}