I have a String like this:
[["123","Albert","foo"],["456","Mark","bar"],["789","Jackson","baz"]]
How can I do to turn it into a corresponding array?
I get this response from a HttpPost in Java (Android).
Thanks in advance
I have a String like this:
[["123","Albert","foo"],["456","Mark","bar"],["789","Jackson","baz"]]
How can I do to turn it into a corresponding array?
I get this response from a HttpPost in Java (Android).
Thanks in advance
Try this.
JSONArray new_array = new JSONArray(string);
for(int i =0; i < new_array.length(); i++){
JSONArray arr = new_array.getJSONArray(i);
for(int j =0; j < arr.length(); j++){
Log.v("result--",""+arr.getString(j));
}
}
Use GSON
like:
Gson gson = new Gson();
String[][] myTypes = gson.fromJson(str, String[][].class);
search for more example of how to use GSON library.
In your format you have to fetch your data for JSONArray instead of JSONObject.
So you have to use this which make sense
JSONArray jArray = new JSONArray(yourResponsestr);
for(int i =0; i < jArray .length(); i++){
JSONArray arr = myarray.getJSONArray(i);
for(int j =0; j < myarray.length(); j++){
Log.v("Response Array -->",""+arr.getString(j));
}
}