I’m working on an n8n automation where I need to iterate through a collection of dictionary objects. My goal is to pull out the ‘loc’ field values from each dictionary and use them as individual items in my loop process. I’ve been trying different approaches but can’t seem to get it working correctly. The workflow keeps failing or not returning the expected results. I’m wondering if there’s a specific way to access nested dictionary properties during loops in n8n. Has anyone dealt with similar data extraction scenarios? What’s the proper syntax or method to grab these specific values from each dictionary object as I iterate through them? Any guidance on the correct approach would be really helpful since I’m stuck on this part of my automation.
use the code node instead of split batches - much cleaner for dicts. loop through your array with for (const item of items)
and push item.loc
to results. I’ve used this approach for years without any probs on nested properties.
Had this exact problem with API location data. Set up an Item Lists node pointing to your main data array before the loop. Inside the loop, use {{ $node["Item Lists"].json["loc"] }}
to grab the field you need. Your data structure needs to be consistent across all objects - inconsistent structure gives you undefined values that’ll break everything. I throw an IF node after extracting the loc value to catch empty or broken entries before they screw up other nodes. Pro tip: use the expression editor preview to test your syntax first - saves tons of time debugging.
Hit this same problem a few months ago while building a customer data workflow. What finally worked: use Split In Batches first, then grab dictionary values with proper JSONPath syntax. Inside the loop, reference the current item like {{ $json["loc"] }}
to pull that field. Your input needs to be an array of objects before you start iterating. I threw in a Set node right after the split to double-check I was getting the right values before moving on. The workflow debugger saved my ass for troubleshooting these dictionary patterns. Watch out for exact field name matches - case sensitivity got me at first.