# Please help with json\_query filter

**URL:** <https://forum.ansible.com/t/please-help-with-json-query-filter/24461>\
**Category:** Ansible Project\
**Created:** [May 11, 2017, 11:55am UTC](https://forum.ansible.com/t/please-help-with-json-query-filter/24461 "2017-05-11T11:55:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![VenomMsk](https://avatars.discourse-cdn.com/v4/letter/v/eb9ed0/32.png) [@VenomMsk](https://forum.ansible.com/u/VenomMsk)\
**Post date:** [May 11, 2017, 11:55am UTC](https://forum.ansible.com/t/please-help-with-json-query-filter/24461/1 "2017-05-11T11:55:29Z")

</div>

Hi everybody!

I have a JSON structure like this:

raw\_list= [  
{ content: [  
{ name: name1, prop: val1},  
{ name: name2, prop: val2}  
]},  
{ content: [  
{ name: name3, prop: val3}  
]}  
]

and I need to get from this arrays of names like this:

[[name1, name2], [name3] ]

How can I achieve that?

If I leave only one element of the initial array, then I can filter it using

json\_query(content[\*].name)

I get one array ([name1, name2]), but I need an array of arrays. I tried to use

json\_query([_].content[_].name)

but it doesn’t work, I get ampty variable

I would really appritiate any help!!!

Best Regards,  
Ivan

---

<div class="post-metadata">

**Author:** ![j.r.hawkesworth](https://avatars.discourse-cdn.com/v4/letter/j/a3d4f5/32.png) [@j.r.hawkesworth](https://forum.ansible.com/u/j.r.hawkesworth)\
**Post date:** [May 12, 2017, 11:21am UTC](https://forum.ansible.com/t/please-help-with-json-query-filter/24461/2 "2017-05-12T11:21:19Z")

</div>

Not sure about your specific issue, but I noticed that the JMESPath examples page [http://jmespath.org/examples.html](http://jmespath.org/examples.html) is actually dynamic, so you can paste in your own json structures and test them out - hope that helps,

Jon

---

<div class="post-metadata">

**Author:** ![sivel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sivel/32/1198_2.png) [@sivel](https://forum.ansible.com/u/sivel)\
**Post date:** [May 12, 2017, 11:34am UTC](https://forum.ansible.com/t/please-help-with-json-query-filter/24461/3 "2017-05-12T11:34:19Z")

</div>

I think you can get this with the map filter pretty easy also:

raw\_list|map(attribute=‘content’)|map(attribute=‘name’)|list
