对于功能API get-request,我具有以下GET响应。我想在json对象中更新相应参数的值,如下所示:
“ paramValue”:15
“ configState”:“启用”
获取请求任务:
- name: Enable feature bit/parameters
uri:
url: https://<API REQUEST URL >
method: GET
return_content: yes
status_code: 200
headers:
Content-Type: application/json
Cookie: "{{ login.set_cookie.split(';')[0] }}"
body_format: json
register: api_result
changed_when: false
failed_when: api_result.status != 200
- debug:
msg: "{{ api_result }}"
GET响应输出:
任务[调试] *********************************************** ****************************************************** ************************ 好的:[localhost] => { “ msg”:{ “已更改”:错误, “连接”:“关闭”, “ content_length”:“ 126”, “ content_type”:“ application / json”, “饼干”: {}, “ date”:“ 2019年2月27日,星期三,格林尼治标准时间”, “失败”:错误, “ json”:{ “ configClass”:“ MASTER”, “ configState”:“ DISABLE”, “ id”:“ FEATURE-BIT”, “ instanceId”:0, “ paramValue”:0, }, “ msg”:“确定(126字节)”, “重定向”:false, “状态”:200, } }
我不确定语法,如何更新json对象中的值/标志以及使用URI模块发送POST请求。请指教吗?