0

Following is the JSON response i have got from a web service. I want to parse it in an android app:

{"text":["Gayatri Hari Mankar","Prajaval V. Kakade","ram  joshi","Revati R Sharma","Sneha M Verma","Sumeet N Wankar"],"status":1000}

I want to retrieve all the names under the text array.

Its a different case than that of the one mentioned below. how to parse JSONArray in android

Community
  • 1
  • 1
Swapnil Lanjewar
  • 646
  • 10
  • 26
  • @Vishwa --its a json response sir i have hit the service through a rest client and i got this response. Its a valid one because it has curly braces and square braces also. Anyways thanks for your response! – Swapnil Lanjewar Aug 18 '15 at 12:55
  • possible duplicate of [how to parse JSONArray in android](http://stackoverflow.com/questions/17136769/how-to-parse-jsonarray-in-android) – Sufian Aug 24 '15 at 11:11

1 Answers1

1

It's just simple parsing of array with variable length.

JSONObject wholeObject = new JSONObject(); //add your response here, from string for example
JSONArray textArray = wholeObject.getJSONArray("text");
for (int i = 0; i < textArray.length(); i++) {
    Log.d("text", textArray.getString(i) );
}
poss
  • 1,759
  • 1
  • 12
  • 27