Try like

- debug:
msg: '{{ data | json_query(query) }}'
vars:
query: '[?number==`"{{ vlan }}"`]'

On Thu, Feb 4, 2021 at 1:52 PM [email protected] <[email protected]>
wrote:

> Hi all,
>
> I am trying to search for a number with a json_query but result is always
> "".
>
> Part of JSON is:
>
> "json": {
>         "code": 200,
>         "success": true,
>         "data": [
>             {
>                 "vlanId": "430",
>                 "domainId": "3",
>                 "name": "Default",
>                 "number": "1",
>                 "description": "Default VLAN",
>                 "editDate": null,
>                 "customer_id": null,
>                 "custom_Topdesk": null
>             },
>             {
>                 "vlanId": "431",
>                 "domainId": "3",
>                 "name": "vlanname",
>                 "number": "3",
>                 "description": " vlanname  ",
>                 "editDate": null,
>                 "customer_id": null,
>                 "custom_Topdesk": null
>             },
>
> Ansible command i am using is:
>
> - name: Determine VLAN ID
>       set_fact:
>
>         vlan_id: "{{ ipam_vlans_filterby_domainid.content.data }} | 
> json_query('[? number == ` ~ vlan ~ `]|[0].vlanId') }}"
>
> variabele vlan for example is: "3"
>
> I found on internet there are some bugs regarding this and some work
> arounds but not able to get it solved.
> Does some one has an idea?
>
> Kind regards,
>
> Danny
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/7c2dcb43-ccc0-423b-8b4d-9fe69cfc585fn%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/7c2dcb43-ccc0-423b-8b4d-9fe69cfc585fn%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>


-- 
Thanks,
Abhijeet Kasurde

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAFwWkHqyHLr-cmOdLBFE285Xct2BNPsKhu5_JGOpZJ5uD_5Y_Q%40mail.gmail.com.

Reply via email to