Json To Array List Conversion
Below is my json code, I can't convert it to arraylist: {'location':[{'place_name':'Arabian Ranches ,Dubai Land'},{'place_name':'The Greens & The Views ,Emirates Living'},{'pla
Solution 1:
in here location is a JsonArray object. so use an integer variable for access data from it :)
ArrayList<String> data=newArrayList<String>();
for(int i=0;i<location.length();i++){
JSONObject arrayElement=location.getJSONObject(i);
data.add(arrayElement.getString("place_name"));
Log.i("json",data.get(i));
}
Solution 2:
change Log.d(location.getJSONObject("place_name"));
to
Baca Juga
- What's The Difference Between Thread.setpriority() And Android.os.process.setthreadpriority()
- How To Handle String Response From Php Using Android Volley Jsonobjectrequest [com.android.volley.parseerror: Org.json.jsonexception]?
- Retrofit2: Convert Json With Dynamic Keys To A Map With Model Also Containing Those Keys
Log.d(location.getJSONObject(i).getString("place_name");
Post a Comment for "Json To Array List Conversion"