I am trying to convert an array of objects into an array of strings inside a for loop.
I am extracting a property from the object the title inside the loop I have several title strings, now I want to pass that into a new array?
JSONArray shots = response.getJSONArray("shots");
for (int i=0; i < shots.length(); i++) {
// play with data
JSONObject post = shots.getJSONObject(i);
String title = post.getString("title");
// turn title into an array of strings??
}
EDIT:
I tried this
String[] mStrings = new String[15];
JSONArray shots = response.getJSONArray("shots");
for (int i=0; i < shots.length(); i++) {
// play with data
JSONObject post = shots.getJSONObject(i);
String title = post.getString("title");
//Log.d("this is my array", "arr: " + title);
mStrings[i] = title;
}
Log.d("this is my array", "arr: " + mStrings);
the result of Log.d was D/this is my array﹕ arr: [Ljava.lang.String;@4294e620