I have the following json structure:
{
"item1": "abc",
"item2": 123,
"item3": true,
"item4": ["a", "b","c"],
"item5": [
[1,2,3],
["x","y","z"],
[
{"five20":["i","j","k"]},
{"five21":"opq"}
]
]
}
I have no problems (yet) with items 1 to 4 which have primitive data types.
Item5 is a List of 3 list items (multidimentional array) of different types of variables (Int, String, Map respectively)
I tried to access the 3rd element of item5 as follows:
But I got the error:
java.lang.IndexOutOfBoundsExecption: Index: 2, Size: 2
Debug at breakpoint also shows that only the first two elements of item5 are recognized.
How can I access the third element which contains Maps?
{
"item1": "abc",
"item2": 123,
"item3": true,
"item4": ["a", "b","c"],
"item5": [
[1,2,3],
["x","y","z"],
[
{"five20":["i","j","k"]},
{"five21":"opq"}
]
]
}
I have no problems (yet) with items 1 to 4 which have primitive data types.
Item5 is a List of 3 list items (multidimentional array) of different types of variables (Int, String, Map respectively)
I tried to access the 3rd element of item5 as follows:
B4X:
Dim JSON As JSONParser
Dim Map1 As Map JSON.Initialize(File.ReadString(File.DirAssets, "myfile.json"))
Map1 = JSON.NextObject
'
'
Dim strJ As String
strJ = Map1.Get("item5").As(List).Get(2).As(List).Get(0).As(Map).Get("five20").As(List).Get(1) ' should give me "j"
But I got the error:
java.lang.IndexOutOfBoundsExecption: Index: 2, Size: 2
Debug at breakpoint also shows that only the first two elements of item5 are recognized.
How can I access the third element which contains Maps?