search a dict with json_query

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!