android java.lang.string无法转换为jsonarray

时间:2013-08-29 09:15:10

标签: java android json string exception

我已经在互联网上搜索了一段时间,仍然不知道该怎么做...这是我的代码:

String res = "...";
        JSONArray jArr = new JSONArray(res);

res包含以下内容:

[["000000000001","club1","www.example.com","some adress"],["000000000002","club2","www.example.com","some adress2"]]

我只是不断收到此错误并且不知道如何修复它,请帮助:C

1 个答案:

答案 0 :(得分:0)

我尝试了你的代码并且工作正常。这是我试过的代码:

String res = "[[\"000000000001\",\"club1\",\"www.example.com\",\"some adress\"],[\"000000000002\",\"club2\",\"www.example.com\",\"some adress2\"]]";
        try {
             jArr = new JSONArray(res);
        } catch (JSONException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        Log.e("Array", "" + jArr.toString());

这是输出:

[["000000000001","club1","www.example.com","some adress"],["000000000002","club2","www.example.com","some adress2"]]