Hello - I have a question about looping over json data I’ve received from calling a REST api using the URI module. I’ve been tearing my hair out over the last several days trying to sort this out…and have googled extensively - but haven’t gotten anywhere. I think it has to do with the difference between a dict, and array, and a list…but i’m new-ish to ansible and not understanding what i’m doing wrong. Any help greatly appreciated.
I can access individual items from the array by doing this: registered_variable.json.data[1]
I can access attributes of individual items from the array by doing this: registered_variable.json.data[1].name
But whenever I try to use with_dict or with_items to loop over registered_variable.json.data....I just get an "item is undefined error" (for example)
- debug:
msg: "{{
item.name}} is the name of the device"
with_dict: "{{registered_variable.json.data}}"
I also tried first storing the object in a variable first:
- set_fact:
devices: "{{ registered_variable.json.data }}"
- debug:
with_dict: devices
I am running on the latest dev from checkout (2.0.0)
Any suggestions?
Thanks in advance!