Yep. But you don’t have to store objects for each row with a row number name. That is needlessly complex. JSON already has an ordered element: array. So you can just do an array of arrays like this for 2D (normal spreadsheet):
[
[
50,
10,
5,
50
],
[
51,
9,
6.5,
58.5
]
]
…and for 3D, just do an array of arrays of arrays. Here is your data:
[
[
[
40.65,
20.3,
120.92,
86.12,
99.33
],
[
10.35,
90.1,
10.52,
1.12,
59.3
],
[
10.65,
62.1,
12.12,
96.23,
19.3
]
],
[
[
96.37,
67.13,
312.62,
87.11,
87.18
],
[
90.94,
41.04,
63.01,
9.1,
30.3
],
[
11.98,
99.01,
41.3,
16.04,
10.4
]
],
[
[
11.88,
12.98,
182.22,
13.84,
81.09
],
[
50.35,
10.1,
10.52,
8.12,
91.3
],
[
88.51,
21.66,
81.13,
36.13,
97.3
]
]
]
…or, minified:
[[[40.65,20.3,120.92,86.12,99.33],[10.35,90.1,10.52,1.12,59.3],[10.65,62.1,12.12,96.23,19.3]],[[96.37,67.13,312.62,87.11,87.18],[90.94,41.04,63.01,9.1,30.3],[11.98,99.01,41.3,16.04,10.4]],[[11.88,12.98,182.22,13.84,81.09],[50.35,10.1,10.52,8.12,91.3],[88.51,21.66,81.13,36.13,97.3]]]
You can access it with JSONArray.
String jsondata = "[[[40.65,20.3,120.92,86.12,99.33],[10.35,90.1,10.52,1.12,59.3],[10.65,62.1,12.12,96.23,19.3]],[[96.37,67.13,312.62,87.11,87.18],[90.94,41.04,63.01,9.1,30.3],[11.98,99.01,41.3,16.04,10.4]],[[11.88,12.98,182.22,13.84,81.09],[50.35,10.1,10.52,8.12,91.3],[88.51,21.66,81.13,36.13,97.3]]]";
JSONArray ja = parseJSONArray(jsondata);
int row = 2;
int col = 0;
int val = 1;
float val = ja.getJSONArray(row).getJSONArray(col).getFloat(val);
println(val); // 182.22
…and you can wrap that code up in a function to make it shorter:
float ja3Dfloat(JSONArray ja, int row, int col, int item){
return ja.getJSONArray(row).getJSONArray(col).getFloat(val)
}
//...
ja3Dfloat(ja, 2, 0, 1); // 182.22