如何在没有KEY:VALUE对的情况下解析android中的json数组?

时间:2014-03-15 06:27:36

标签: android

我有来自服务器的以下输出。如何在android中解析它?需要帮忙。

 [["1","shopknock","0","0","22","18.5123","73.8563"],["2","Food Shopei","231","1","17","18.5122","73.8562"],["10","Ccd","0","0","22","18.5211","73.857"]]

2 个答案:

答案 0 :(得分:3)

[表示json数组节点

解析

JSONArray jr = JSONArray("your json string");
for(int j=0;j<jr.length;j++)
{ 
JSONArray jr1 = (JSONArray)jr.getJSONArray(j);
for(int i=0;i<jr1.length();i++)
{
     String value = (String)jr1.get(i);
}
}

答案 1 :(得分:0)

您需要使用JSONObject和JSONArray类。通过以下链接清除您的概念:

http://www.json.org/javadoc/org/json/JSONArray.html

然后,通过下面的教程,它提供了一个名为ServiceHandler.java的类来处理你的json解析。这很容易:

http://www.androidhive.info/2012/01/android-json-parsing-tutorial/