how to access multidimensional array

Aysic4Bandroid

Member
Licensed User
Longtime User
hi,

Can anyone clarify how i access an array inside another array in a JSON string - i know this is how to reference the outer array in the first index:
B4X:
map1 = list1.Get(0)

If this array index contains another nested array (rather than an object) can i access it thus:
B4X:
map1 = list1.Get(0)(0)

If not, what is the correct way an object such as this in a JSON string maps to a b4A List

thanx :sign0163:
 

Aysic4Bandroid

Member
Licensed User
Longtime User
Erel,

Ok excuse my use of the word multidimensional - but i see them as such even though they are really 'lists' in b4A - So how do i get to the list within the first index - ive attached a 'JSON 2 HTML' generated diagram to help visualize my json string:

In your tutorial on JSON someone asked a similar question and you gave them code similar to that included in my original thread - that helps me access the first Object (index 0) my question now is what is the syntax to reference and iterate over inner array which all have the same format ?? do i need to DIM two separate lists and two maps.
 

Attachments

  • JSON-2-HTML.png
    JSON-2-HTML.png
    38.5 KB · Views: 330
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
any ideas so i don't have to re-post for the 3rd time
I'm afraid that you will need to be more patient...

If I understand correctly from the image, your main list includes two items. The second item (in index 1) is another list that holds several Maps. You should declare an additional list object and then set it with the value of MainList.Get(1).
 
Upvote 0

Aysic4Bandroid

Member
Licensed User
Longtime User
Thanks for that - i was completely on the wrong tracks my apologies Erel - didn't mean to appear hasty - just got caught up with with one i keep hitting brick walls in the learning of how things work in B4a - just frustration (with myself mainly).
 
Upvote 0
Top