unpacking arrays of dicts within dicts

Jason Charney's icon

I'm wanting to get some info from the USGS Earthquake feed. The JSONs come in in GeoJSON format, with "type", "metadata," and "features" as keys in the top-level hierarchy that comes in. The salient info I need is in the "features" dictionary, which itself seems to be an array of dictionaries.

When I try to use [dict.unpack] at "features" I only get the list of the properties of the first item in [dict.view]./[dict.print]. How do I get ALL of the features objects in this same level of the hierarchy? The [dict] does show there are a number of dictionaries equal to the number in the array when I sent "get features" to the dict that all the data is stored in.

Do I need to like...iterate through the numbers in the array of features - e.g. "getfeatures[1], getfeatures[2]..." for every since "features" object in the full JSON object? There's gotta be a better way.

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

Michael Begg's icon

Hi - Did you ever get this one solved? I have the same issue - except with air quality data rather than earthquakes!

Nathan Berwick's icon

Sorry if I'm late to the party, but I've had a similar issue and solved using "unpack dict dict" to split apart each "feature". One can then work on each "feature" separately.

I'm still working on how to get this to loop nicely but I hope this helps

Eric L.'s icon

Hi Nathan,
could you please share a Max patch with "unpack dict dict" ?
Many thanks,

yaniki's icon