# How to make sure that values for all keys with same name are strings?

**URL:** <https://forum.ansible.com/t/how-to-make-sure-that-values-for-all-keys-with-same-name-are-strings/38566>\
**Category:** Ansible Project\
**Created:** [November 3, 2023, 12:57pm UTC](https://forum.ansible.com/t/how-to-make-sure-that-values-for-all-keys-with-same-name-are-strings/38566 "2023-11-03T12:57:01Z")\
**Posts on this page:** 4\
**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:** [November 3, 2023, 12:57pm UTC](https://forum.ansible.com/t/how-to-make-sure-that-values-for-all-keys-with-same-name-are-strings/38566/1 "2023-11-03T12:57:01Z")

</div>

Hii,

I have a structure like this:

---

<div class="post-metadata">

**Author:** ![Will\_McDonald](https://avatars.discourse-cdn.com/v4/letter/w/f475e1/32.png) [@Will\_McDonald](https://forum.ansible.com/u/Will_McDonald)\
**Post date:** [November 3, 2023, 1:34pm UTC](https://forum.ansible.com/t/how-to-make-sure-that-values-for-all-keys-with-same-name-are-strings/38566/2 "2023-11-03T13:34:04Z")

</div>

Do you need to do this natively handling the data structure in a playbook or would a degree of preprocessing be OK?

You might be able set the style using yq as one option? Possibly in combination with key matching?

[https://mikefarah.gitbook.io/yq/operators/style#set-single-quote-style](https://mikefarah.gitbook.io/yq/operators/style#set-single-quote-style)

---

<div class="post-metadata">

**Author:** ![Andrew\_Latham](https://avatars.discourse-cdn.com/v4/letter/a/ed8c4c/32.png) [@Andrew\_Latham](https://forum.ansible.com/u/Andrew_Latham)\
**Post date:** [November 3, 2023, 3:44pm UTC](https://forum.ansible.com/t/how-to-make-sure-that-values-for-all-keys-with-same-name-are-strings/38566/3 "2023-11-03T15:44:51Z")

</div>

I saw [https://github.com/ansible/proposals/issues/72](https://github.com/ansible/proposals/issues/72) and thought that maybe the history may help.

I can remember padding with a space to keep an ID a string that the consumer filters out but YMMV

---

<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:** [November 3, 2023, 11:20pm UTC](https://forum.ansible.com/t/how-to-make-sure-that-values-for-all-keys-with-same-name-are-strings/38566/4 "2023-11-03T23:20:42Z")

</div>

Turns out the problem isn’t so much with the yaml, but with the ‘yq’ that I use to fetch some values from it.

That yq is the one from PyPI, and interprets the string 036001814778 as an int and then chokes on it:

dick.visser@GA dick$ cat foo.yml  
state:  
owner\_id: 036001814778  
dick.visser@GA dick$ yq -r . foo.yml  
yq: Error running jq: ValueError: invalid literal for int() with base 8: ‘036001814778’.

There is an issue about this ([https://github.com/kislyuk/yq/issues/152](https://github.com/kislyuk/yq/issues/152)) and that seems to have been fixed this very week.  
I could wait for that.

But, for my use case (a state file that contains some AWS infra), I figured I’d rather avoid any more YAML issues and just use a JSON file instead (which works).

thx!
