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:
Felix Fontein 2025-08-02 16:42:34 +02:00 committed by GitHub
commit 3de073fb6f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 33 additions and 5 deletions

View file

@ -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"