【发布时间】:2020-02-08 03:23:05
【问题描述】:
我正在尝试使用 Ansible 解析我的 JSON,但遇到了问题。我需要来自 JSON 响应的密码
我的 JSON 响应示例是
{
"James Params": {
"01. name": "james bond",
"02. phone": "334455667788",
"03. height": "5.10",
"04. country": "UK",
"05. pincode": "10000",
"06. city": "london",
}
}
我的剧本代码是
- name: Submit and read the JSON response
uri:
method: GET
url: "http://URL_UNDER_TEST"
return_content: yes
headers:
Accept: application/json
register: response
- debug:
msg: "{{response.json.'James Params'.'05. pincode'}}"
我收到以下错误:
致命:[本地主机]:失败! => {"msg": "模板错误,同时模板字符串:预期的名称或数字。字符串:{{response.json | json_query(\"James Params\".\"05.pincode\")}}"}
请求帮助。
【问题讨论】:
标签: ansible ansible-2.x