how to create hierarchical dictionary structures?

benj3737's icon

Hello,
Quick question:
I want to create a hierarchical dictionary but don't know how. I've read the documentation and scoured the web but haven't found anything applicable. If an explanation is out there, a link would be much appreciated.

Here's probably the best way to illustrate my question: create a dict object, open the help file, click the hierarchy tab, and double-click dict bicycle.

It contains nested sub-dicts, which seems like a powerful and elegant way to manipulate hierarchical data.

What messages would I send an empty dict to create the contents of 'dict bicycle'? Specifically creating sub-dicts

Does that make sense?

Any help greatly appreciated!

Thanks
Ben

benj3737's icon

I think I'm on the track with the dict.pack object

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

I tried to explain in more depth, but the forum doesn't copy my formatting, so I included the code to a comment box explaining:

luke.schantz@gmail.com's icon

I had some issues with this as well. Last week I was pulling out my hair looking for this solution. There is only documentation on how to parse the hierarchy. I found some patch that had an instance of formatting. Please check out the attached example I made.

I am still working though some of the nuances of formatting these. Today is trying to make an array of objects with the same keys.

5527.nTangleHierarchicalJSONObjectPatch0.maxpat
Max Patch
luke.schantz@gmail.com's icon

I deleted the last attached file and reposted it.

5528.HierarchicalJSONObjectPatch001.maxpat
Max Patch
Tarik's icon
Max Patch
Copy patch and select New From Clipboard in Max.

For whoever may be interested - Just wondered about the same topic and somewhere within the dict reference I found the beauty of the 'replace' message. Copy-paste the following to see how easy it is to make nested dictionaries:

loadmess's icon

Yes, agree. The documentation seems detailed for each dict object, but then seems that doesn't explain (a tutorial or example) how to setup a more complex structure, where everything interacts together.

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

Hi, I have another problem I can't solve, please for help... the patch is this, subDict2 has two items with id 1 and 2 (but they are not expressed if you open the dictionary editor):

Thanx for helping.

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

Solved.