0

I have following output from server. How to parse it in android? Need help.

 [["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"]]
1
  • make sure its a valid json. if its a json array you can get the value based on the index Commented Mar 15, 2014 at 6:32

2 Answers 2

3

[ represents a json array node

To parse

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);
}
}
Sign up to request clarification or add additional context in comments.

Comments

0

You need to use JSONObject and JSONArray class. Go through the below link to clear your concept on these:

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

Then, go through the below tutorial, it provides a class called ServiceHandler.java to handle your json parsing. It is quite easy:

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.