我有以下字典,里面有一个列表(项目)
{
"json": {
"data": {
"devices": {
"items": [
{
"configurationStatus": "SYNCED",
"conflictDetectionState": "IN_SYNC",
"connectivityState": "ONLINE",
"deviceType": "ASA",
"highAvailability": "OFF",
"interfaces": null,
"specificDevice": {
"namespace": "asa",
"type": "configs",
"uid": "12313131231",
"vpnId": null
},
"uid": "1231312313"
}
],
"metadata": {
"count": 1
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
我已将此输出注册在名为“输出”的变量下。如果我逐行查找项目,我可以毫无问题地访问它们
- debug:
var: output.json
Run Code Online (Sandbox Code Playgroud)
好的!
- debug:
var: output.json.data
Run Code Online (Sandbox Code Playgroud)
好的!
- debug:
var: output.json.data.devices
Run Code Online (Sandbox Code Playgroud)
好的!
- debug:
var: output.json.data.devices.items
ok: [localhost] => {
"output.json.data.devices.items": "<built-in method items of …Run Code Online (Sandbox Code Playgroud) ansible ×1