0

I want to parse the following data, everything is done but i'm confused at this last stage:

["ABC","DEF","GHI"]

How can I parse this type of json data?

1
  • sorry for my english Commented Aug 18, 2015 at 11:29

1 Answer 1

1

Do it like this

JSONArray arr = new JSONArray(data); // assuming your json array is store in data
for(int i = 0; i < arr.length(); i++)
{
    String str = arr.getString(i); // will return one string at a time
}
Sign up to request clarification or add additional context in comments.

5 Comments

thanks, i m retrieving data from server, so how to create this JSONArray object.. JSONObject jsonObj = new JSONObject(jsonStr); from this.
Please post the code where you are getting this json
jsonArray = jsonObj.getJSONArray(""); JSONArray arr = new JSONArray(data);
data is the variable where ["ABC","DEF","GHI"] is stored. try this.
I have JSONObject, see this JSONObject jsonObj = new JSONObject(url); ok? Now how to create JSONArray object?

Your Answer

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