I'm not sure if this answers your question but I think you can always use iterator and split, for instance:
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import net.sf.json.JSONObject;
public class test {
/**
* @param args
*/
@SuppressWarnings("unchecked")
public static void main(String[] args) {
Map <String, Object> map1 = new HashMap<String, Object>();
Map <String, Object> map2 = new HashMap<String, Object>();
Map <String, Map> map3 = new HashMap<String, Map>();
map1.put("0","22,32,21");
map1.put("1", "2762,352,231");
map2.put("0", "222,232,621");
map2.put("1","272,37762,261");
map3.put("0",map1 );
map3.put("1",map2);
JSONObject jsonobj = JSONObject.fromObject(map3); // creating json object
Iterator it = jsonobj.keys();
int maxZ = 0; //find out the length of the last dimension
while(it.hasNext()) {
JSONObject jobj = (JSONObject) jsonobj.get(it.next());
Iterator it2 = jobj.keys();
while(it2.hasNext()) {
if(((String)jobj.get(it2.next())).split(",").length > maxZ){
maxZ= ((String)jobj.get(it2.next())).split(",").length;
}
}
}
int[][][] result= new int [jsonobj.size()][2][maxZ]; //creating 3D array of the right size
int x = 0, y = 0, z = 0;
it = jsonobj.keys();
while(it.hasNext()) {
JSONObject jobj = (JSONObject) jsonobj.get(it.next());
Iterator it2 = jobj.keys();
y = 0; //reset y
while(it2.hasNext()) {
String[]s =((String)jobj.get(it2.next())).split(",");
z = 0; //reset z
for (String str : s) {
result[x][y][z] = Integer.parseInt(str);
z++;
}
y++;
}
x++;
}
for (int i = 0; i < x; i++) {
for (int j = 0; j < y; j++) {
for (int k = 0; k < z; k++) {
System.out.print(result[i][j][k]);
System.out.print(" ");
}
System.out.println("\n");
}
}
}
}
output:
272 37762 261
222 232 621
2762 352 231
22 32 21
not sure why this is in the back order, sorry if this doesn't help :P