Listing and outputting values of nested dictionaries

kflak's icon
Max Patch
Copy patch and select New From Clipboard in Max.

So, I've been working on the cueing part of a big patch, and found the dict to be perfect for my needs (after a looooong time testing and mucking about with various coll solutions that invariably were a major pain to work with.). I even managed to get a patch working that would spit out all the values of nested (one deep) dictionaries as a response to the name of the key. So, basically, what I want to do is to iterate through all the keys and output both the key and the values. Using a collection of zl's and dict.iter objects made that task relatively painless. What was NOT painless was to try and do the same with a javascript! So basically, what I would like to know is how to pull off this stunt in js? How can I access the dicts that are nested in a dict if I don't know their names in advance? See patch below for details on how I finally solved the problem with Max objects...

kflak's icon

and here is the body of the MBCues.json:

{
    "CueControl 1.0" : "KF_2015",
    "init" :     {
        "1playlist_level_" : 0.6,
        "1playlist_" : 1,
        "1playlist_folder" : "treeperc/",
        "follow" : 2000
    }
,
    "second_cue" :     {
        "whatever" : 16
    }
,
    "tweener" :     {
        "whatever" : 4,
        "ok" : 5
    }
,
    "third_cue" :     {
        "yetagain" : "value2"
    }
,
    "fourth_cue" :     {
        "sendingsending" : "value1"
    }

}

Floating Point's icon

have a look at this thread:

I think it contains answers to your problem, if you use the js object

kflak's icon

Thanks, floating point! Will take a deeper peek into it when I have a free moment. Looks very promising at first glance...