Create and iterate through three dimensional JSON object

I’ve looked at quite some topics about the matter on this site, but i can’t seem to find a understandable solution for my approach.

I have a situation where i want to fill three select boxes with options from a multidimensional (JSON ?) array with a relation like this:

Country > Region > City

Every country has multiple regions and each region has multiple cities

I thought of something like this

var destination = {
    'country' : 'Germany',
    'area' : [{
        'Beieren' : [{
            'city' : [{
                '0' : 'Mitwitz'
        'Beieren Beierse Woud' : [{
            'city' : [{
                '0' : 'St. Englmar', 
                '1' : 'Waldmünchen', 
                '2' : 'Arrach'

But apparently that isn’t the way to go since gives me the last occurrence of country (Germany in this case) but then i get stuck.

I probably took a wrong turn somewhere in the making of the data array, but i don’t know how to het back on track.

Any help would be appreciated!

Source: json

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.