Try next one method:
public class Test
{
public static void main(String[] args) throws JSONException
{
String data = "[{\"userName\": \"sandeep\",\"age\":30},{\"userName\": \"vivan\",\"age\":5}] ";
JSONArray jsonArr = new JSONArray(data);
for (int i = 0; i < jsonArr.length(); i++)
{
JSONObject jsonObj = jsonArr.getJSONObject(i);
System.out.println(jsonObj);
}
}
}
This way I used and it coincides with the opinion of people on Stackoverflow.
Check next source: https://stackoverflow.com/questions/15609306/convert-string-to-json-array/source
Regards,
Jame Corbitt