Accessing nested data in dicts (JS example)

Charles Matthews's icon

I can't tell if I'm trying to misuse dictionaries but I'd really like to use them to make nested data structures - something I've been doing rather awkwardly with pattr up until now.

I can see a couple of other people on here are trying to do similar things and wondering if anyone has any advice. My biggest problem at the moment is finding a way to get information in without overwriting other entries - kind of along the lines of this https://cycling74.com/forums/dict-merge-method but working with dicts inside dicts with a varying number of levels.

I've attached a little bit of JavaScript I'm using to access the data - I'm very new to JS so there might be a better way of doing it but it seems to work. I hope it might be useful for someone.

I have tried to do something similar in reverse (i.e. set level nextlevel value) but without any luck. I can post that up if anyone's interested in looking at my messy code.

2920.dictexample.zip
zip
Charles Matthews's icon
Max Patch
Copy patch and select New From Clipboard in Max.

Here's an example of some data I'm working with - starting to get a few more levels in now. JSON seems to be the best way to store this either way so I'm sorting out the structure by hand for the time being.