相关疑难解决方法(0)

将Json数组转换为普通Java数组

有没有办法将JSON数组转换为普通的Java Array for android ListView数据绑定?

java android json

127
推荐指数
5
解决办法
22万
查看次数

将JSONArray转换为String Array

我想问一个关于将a转换jsonArray为StringArrayon的问题Android.这是我jsonArray从服务器获取的代码.

try {
    DefaultHttpClient defaultClient = new DefaultHttpClient();
    HttpGet httpGetRequest = new HttpGet("http://server/android/listdir.php");
    HttpResponse httpResponse = defaultClient.execute(httpGetRequest);

    BufferedReader reader = new BufferedReader(new InputStreamReader(httpResponse.getEntity().getContent(),"UTF-8"));

    String json = reader.readLine();

    //JSONObject jsonObject = new JSONObject(json);
    JSONArray jsonArray = new JSONArray(json);
    Log.d("", json);

    //Toast.makeText(getApplicationContext(), json, Toast.LENGTH_SHORT).show();

} catch (Exception e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
}
Run Code Online (Sandbox Code Playgroud)

这就是JSON.

[
    {"name": "IMG_20130403_140457.jpg"},
    {"name":"IMG_20130403_145006.jpg"},
    {"name":"IMG_20130403_145112.jpg"},
    {"name":"IMG_20130404_085559.jpg"},
    {"name":"IMG_20130404_113700.jpg"},
    {"name":"IMG_20130404_113713.jpg"},
    {"name":"IMG_20130404_135706.jpg"},
    {"name":"IMG_20130404_161501.jpg"},
    {"name":"IMG_20130405_082413.jpg"},
    {"name":"IMG_20130405_104212.jpg"},
    {"name":"IMG_20130405_160524.jpg"},
    {"name":"IMG_20130408_082456.jpg"},
    {"name":"test.jpg"} …
Run Code Online (Sandbox Code Playgroud)

java android json

52
推荐指数
6
解决办法
17万
查看次数

标签 统计

android ×2

java ×2

json ×2