# search a dict with json\_query

**URL:** <https://forum.ansible.com/t/search-a-dict-with-json-query/24452>\
**Category:** Ansible Project\
**Created:** [May 10, 2017, 6:30pm UTC](https://forum.ansible.com/t/search-a-dict-with-json-query/24452 "2017-05-10T18:30:29Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Abhi\_Grover](https://avatars.discourse-cdn.com/v4/letter/a/bbe5ce/32.png) [@Abhi\_Grover](https://forum.ansible.com/u/Abhi_Grover)\
**Post date:** [May 10, 2017, 6:30pm UTC](https://forum.ansible.com/t/search-a-dict-with-json-query/24452/1 "2017-05-10T18:30:29Z")

</div>

Is there a way to convert the following into “set\_fact”, where the {{item.key}} can be assigned to a variable in one line:

- name: search for pools  
set\_fact:  
matched\_pool: “{{item.key}}”  
with\_dict: “{{ bigip\_pools[‘ansible\_facts’][‘pool’] }}”  
when:  
(item.value |json\_query(“member[?address=='” ~ match\_host ~ “']”)) and  
(item.value |json\_query(“member[?port==`" ~ match_port ~ "`]”))

The reason being I am trying to work around the issue where I have a nested loop, using with\_dict, that seems to not make the above work for some reason.

Thanks!
