# Basic "json\_query" features with yaml structures

**URL:** <https://forum.ansible.com/t/basic-json-query-features-with-yaml-structures/34122>\
**Category:** Ansible Project\
**Created:** [October 28, 2020, 3:33am UTC](https://forum.ansible.com/t/basic-json-query-features-with-yaml-structures/34122 "2020-10-28T03:33:59Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![P\_Larsen](https://avatars.discourse-cdn.com/v4/letter/p/ed655f/32.png) [@P\_Larsen](https://forum.ansible.com/u/P_Larsen)\
**Post date:** [October 28, 2020, 3:33am UTC](https://forum.ansible.com/t/basic-json-query-features-with-yaml-structures/34122/1 "2020-10-28T03:33:59Z")

</div>

Hello - i’m trying to figure out how to do this if the data isn’t JSON:

json\_query(host[?name==‘webserver’].ipaddress)

In other words, I want to return an attribute from a list based on a condition. I’m trying to combine data from multiple lists over a shared key.

example:

- system1

- host: demo1  
ipaddress: 192.168.20.20

- host: demo4  
ipaddress: 192.168.20.30

- systemstatus

- system: demo4  
status: faulty

- system: web5  
status: operational

What I would like returned is a single list:  
result:

- host: demo4  
ipaddress: 192.168.20.30  
status: faulty

Currently I’m just looping through “systemstatus” but I how do you do the simple json query above to extract the data from “example”. Or if it helps, I am getting data from a 3rd system and I would like to use it to update the inventory data I have about hosts “I know about”. And I keep coming up short on how to select from an list based on a condition that isn’t the index of the array it’s implemented in.
