I have this example:
---
- hosts: localhost
gather_facts: false
vars:
json1: {'disk_info': {'A': {'label': 'Hard disk 1'}, 'B': {'label': 'Hard disk 2'}}}
json2: {'disk_info': {'0': {'label': 'Hard disk 1'}, '1': {'label': 'Hard disk 2'}}}
tasks:
- debug: msg="{{json1.disk_info.A}}"
- debug: msg="{{item.value.label}}"
loop: "{{ lookup('dict', json2.disk_info) }}"
when: "'0' in item.key"
Is it possible to access json 1.disk_info.0 the same way as json 2.disk_info.A - i.e. without a lookup on a dict?