Unpacking nested dicts as dicts

Michael Begg's icon

Am I missing something?
I have a dict populated by a call to a JSON API - and within it there are sub dicts.
I can access keys and values in these sub dicts using get messages, double colon syntax and square/array brackets, and a simple get message on the key in which the nested dicts are located shows me that there are multiple dicts in there, each with its own identifier (see attached pic).

But so far as I can tell the only way to access the information is through get messages.

Is it not possible to have the dict spit out the nested dictionaries as dict objects?

personal_username's icon

did you try

bang
[dict main]
[dict.unpack nested]
[dict only_nested]

Michael Gary Dean's icon

Just to build on what PERSONAL_USERNAME has said here, there's a few steps I think.

First, you might want to strip the key "results" from the message using the something like [zl.slice 1]. The right outlet will contain the message without the "results" key.

Next, you could separate the different dictionary names using [unjoin 5] since you have 5 dictionaries in the results.

Finally, for each dictionary, you can unpack the keys using [dict.unpack my_key_name: another_key_name:]. Notice the colon after the key name in each case!

Hope that helps you out!

--
Michael Gary Dean
Mighty M4L
mightym4l.com

Teb Geronimo's icon

This will do what you want.
-T

Max Patch
Copy patch and select New From Clipboard in Max.