I have a Problem with parsing a JSON Object. I get the JSON Object from uri. I need the number 13 in the string for the next task. Does anybody know, how it is possible to get only the number from this JSON Object?
- name: GET JOB INFORMATION
uri:
url: "http://******"
method: GET
headers:
Accept: 'application/json'
Content-Type: 'application/json'
Authorization: 'Session {{ xxx.json.token }}'
register: result_job
- name: Output_1
debug:
msg: "{{ result_job.json.affectedResources }}"
- name: Output_2
debug:
msg: "{{ result_job.json.affectedResources.split('/')[0] | last }}"
When ansible execute the Task "Output_2" i got an Error:
{"msg": "The task includes an option with an undefined variable. The error was: 'list object' has no attribute 'split'\n\nThe error appears to have been in
The Output of the Task "Output_1" is this:
"msg": [
"/Manager/tes/objects/bew/13"
]
And the JSON Object look like this:
"msg": {
"affectedResources": [
"/Manager/tes/objects/bew/13"
],
"completedTime": "2022-03-16T..."
"createdTime": "2022...."
}
Thank you!