mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-08-11 16:44:22 -07:00
json_query: extend list of type aliases for compatibility with ansible-core 2.19 (#10539)
* Extend list of type aliases for json_query. * Improve tests. Co-authored-by: Abhijeet Kasurde <akasurde@redhat.com> --------- Co-authored-by: Abhijeet Kasurde <akasurde@redhat.com>
This commit is contained in:
parent
9a29622584
commit
3de073fb6f
3 changed files with 33 additions and 5 deletions
|
@ -11,4 +11,23 @@
|
|||
- name: Test json_query filter
|
||||
assert:
|
||||
that:
|
||||
- "users | community.general.json_query('[*].hosts[].host') == ['host_a', 'host_b', 'host_c', 'host_d']"
|
||||
- >-
|
||||
users | community.general.json_query('[*].hosts[].host') == ['host_a', 'host_b', 'host_c', 'host_d']
|
||||
- >-
|
||||
ports | json_query("[?contains(ports, `22`)]") == [ports[0]]
|
||||
- >-
|
||||
ports | json_query("[?contains(rule_desc, `ssh`)]") == [ports[0]]
|
||||
- >-
|
||||
my_complex_data | json_query('users[?id==`1`]') == [my_complex_data['users'][0]]
|
||||
vars:
|
||||
my_complex_data:
|
||||
users:
|
||||
- id: 1
|
||||
name: Alice
|
||||
roles: ["admin", "dev"]
|
||||
status: active
|
||||
ports:
|
||||
- ports: [22]
|
||||
rule_desc: "ssh"
|
||||
- ports: [80]
|
||||
rule_desc: "http"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue