# simple problem but can't figure it out

**URL:** <https://forum.ansible.com/t/simple-problem-but-cant-figure-it-out/37602>\
**Category:** Ansible Project\
**Created:** [February 1, 2023, 1:56pm UTC](https://forum.ansible.com/t/simple-problem-but-cant-figure-it-out/37602 "2023-02-01T13:56:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dnmvisser](https://avatars.discourse-cdn.com/v4/letter/d/8e8cbc/32.png) [@dnmvisser](https://forum.ansible.com/u/dnmvisser)\
**Post date:** [February 1, 2023, 1:56pm UTC](https://forum.ansible.com/t/simple-problem-but-cant-figure-it-out/37602/1 "2023-02-01T13:56:11Z")

</div>

Hi

I am looking for a way to transform a list of strings into a list of dicts, where the string is a certain key’s value - without using a loop. So from this:

my\_list:

- foo
- bar
- baz

to:

other\_list:

- somekey: foo
- somekey: bar
- somekey: baz

It looks too simple but I can’t see how to do this…

---

<div class="post-metadata">

**Author:** ![Walter\_Rowe](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/walter_rowe/32/4506_2.png) [@Walter\_Rowe](https://forum.ansible.com/u/Walter_Rowe)\
**Post date:** [February 1, 2023, 1:57pm UTC](https://forum.ansible.com/t/simple-problem-but-cant-figure-it-out/37602/2 "2023-02-01T13:57:43Z")

</div>

Look at the ansible filters documentation. They provide examples.

Walter

---

<div class="post-metadata">

**Author:** ![dnmvisser](https://avatars.discourse-cdn.com/v4/letter/d/8e8cbc/32.png) [@dnmvisser](https://forum.ansible.com/u/dnmvisser)\
**Post date:** [February 1, 2023, 2:06pm UTC](https://forum.ansible.com/t/simple-problem-but-cant-figure-it-out/37602/3 "2023-02-01T14:06:30Z")

</div>

ehm, yes, I did get that…

It’s as simple as:

“{{ my\_list | json\_query(‘.{somekey:@}’) }}”
