I have following JSON input:
{
"a goo": {
"link": "google.com"
},
"b ms": {
"link": "microsoft.com"
},
"c amz": {
"link": "amazon.com"
}
}
I'd like get the link string ("google.com"…) according to variable {{ target }} Content of {{ target }} variable will contains one of the "a goo", "b ms", "c amz" string.
Something like:
- name:
set_fact:
target: "c amz"
- debug:
msg: "{{ input.json | json_query('{{ target }}'.link) }}"
Which should show:
msg: "amazon.com"
Thank you for the advice.
+FE