转换JSONarray到ArrayList中 [英] Converting JSONarray to ArrayList
本文介绍了转换JSONarray到ArrayList中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我下载一个JSON字符串,并将其转换成JSONArray。林把它变成一个列表视图,并需要能够从该列表视图后删除,因为JSONArray没有卸下摆臂方法(感谢奥巴马),我试图将其转换为一个ArrayList
下面是我的JSON(与Array.toString()):
[{thumb_url:TB-1370913834.jpg,事项标识:15,伯爵:44,event_tagline:这是一个标语,EVENT_NAME:5岁生日,event_end:1370919600,event_start:1370876400}]
我需要得到它到一个数组中,并能够通过各自的键来调用字符串。鸭preciate任何帮助!
解决方案
的ArrayList<字符串>的ListData =新的ArrayList<字符串>();
JSONArray jArray =(JSONArray),其中的JSONObject;
如果(jArray!= NULL){
的for(int i = 0; I< jArray.length();我++){
listdata.add(jArray.get(ⅰ)的ToString());
}
}
I am downloading a JSON string and converting it to JSONArray. Im putting it into a listview and need to be able to delete from that listview later, and since JSONArray has no .remove method (Thanks Obama), I am trying to convert it to an arraylist.
here is my JSON (the array.toString()):
[{"thumb_url":"tb-1370913834.jpg","event_id":"15","count":"44","event_tagline":"this is a tagline","event_name":"5th birthday","event_end":"1370919600","event_start":"1370876400"}]
I need to get it into an array and be able to call the strings by their respective keys. Appreciate any help!
解决方案
ArrayList<String> listdata = new ArrayList<String>();
JSONArray jArray = (JSONArray)jsonObject;
if (jArray != null) {
for (int i=0;i<jArray.length();i++){
listdata.add(jArray.get(i).toString());
}
}
这篇关于转换JSONarray到ArrayList中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文