Ansible Filter json query: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
(Created page with "=Internal= * Ansible Filter =Overview= =Use Cases= ====Selecting Individual Map Fields from a List of Maps==== <syntaxhighlight lang='yaml'> "{{...")
 
 
(4 intermediate revisions by the same user not shown)
Line 1: Line 1:
=External=
* https://docs.ansible.com/ansible/latest/user_guide/playbooks_filters.html#selecting-json-data-json-queries
=Internal=
=Internal=
* [[Ansible Filter#json_query|Ansible Filter]]
* [[Ansible Filters#json_query|Ansible Filters]]
 
=Overview=
=Overview=


=Use Cases=
=Use Cases=
====Selecting Individual Map Fields from a List of Maps====
====Selecting Individual Map Fields from a List of Maps====
Produce a list:
<syntaxhighlight lang='yaml'>
<syntaxhighlight lang='yaml'>
"{{ find_result.files | json_query('[*].path') }}"
"{{ find_result.files | json_query('[*].path') }}"
</syntaxhighlight>
</syntaxhighlight>
To apply a regular expression to each element of the list, see: {{Internal|Ansible_Filter_regex_replace#Apply_the_Regular_Expression_to_Each_Element_of_a_List|Apply regex_replace to Each Element of a List}}

Latest revision as of 09:15, 5 July 2021

External

Internal

Overview

Use Cases

Selecting Individual Map Fields from a List of Maps

Produce a list:

"{{ find_result.files | json_query('[*].path') }}"

To apply a regular expression to each element of the list, see:

Apply regex_replace to Each Element of a List