2013-08-29 67 views
0

我一直在通過互聯網對搜索的同時,仍然不知道該怎麼辦......這裏是我的代碼:安卓java.lang.String中不能轉化爲jsonarray

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

資源包含以下:

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

我剛得到這個錯誤,不知道如何解決它,請幫助:C

+0

請給錯誤的詳細信息。 – PrvN

+0

[Dublicated](http://stackoverflow.com/questions/11743422/string-cannot-be-converted-to-jsonarray) – Gerret

回答

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"]] 
相關問題