Reputation: 85
So I've got a multiple dimensional array with two columns (the number of columns never changes but the number of rows can) and I get how to store a single dimensional array in a JSONArray but I'm having difficulty wrapping my brain around how to store a multidimensional one. It's the syntax of it that I'm trying to figure out. I've tried searching for the solution myself but all I seem to be getting is information dealing with single dimension arrays.
Upvotes: 0
Views: 268
Reputation: 8106
JSONArray multiArray = (JSONArray) JSONSerializer.toJSON(yourArray);
for(int i = 0; i < multiArray .size(); i++){
for(int j = 0; j < multiArray.getJSONArray(i).size(); j++){
test[i][j] = (String) multiArray.getJSONArray(i).get(j);
}
}
Upvotes: 1