There are probably cleaner ways of doing this with a modern JSON library, but since this way may be easier to understand, I am demonstrating how to do it step by step with the older "Simple JSON" library:
package samplejava;
import java.util.Arrays;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.JSONValue;
public class JsonTest {
public static void main(String[] args) {
JSONArray rows = (JSONArray) JSONValue.parse("[ [\"case1\",[\"case1-a\"]], [\"case2\",[\"case2-a\",\"case2-b\",\"case2-c\"]] ]");
System.out.println("Before: " + rows.toJSONString());
String[][] result = new String[rows.size()][];
for(int row = 0; row < rows.size(); row++) {
JSONArray cols = (JSONArray)((JSONArray) rows.get(row)).get(1);
String[] temp = new String[cols.size()];
for(int col=0; col < cols.size(); col++) {
temp[col] = cols.get(col).toString();
}
result[row] = temp;
}
System.out.println("After: " + Arrays.deepToString(result));
}
}
Output:
Before: [["case1",["case1-a"]],["case2",["case2-a","case2-b","case2-c"]]]
After: [[case1-a], [case2-a, case2-b, case2-c]]