# How to escape doublequote and curly braces

**URL:** <https://forum.ansible.com/t/how-to-escape-doublequote-and-curly-braces/30969>\
**Category:** Ansible Project\
**Created:** [August 7, 2019, 5:06am UTC](https://forum.ansible.com/t/how-to-escape-doublequote-and-curly-braces/30969 "2019-08-07T05:06:47Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rakesh\_Parida](https://avatars.discourse-cdn.com/v4/letter/r/3ab097/32.png) [@Rakesh\_Parida](https://forum.ansible.com/u/Rakesh_Parida)\
**Post date:** [August 7, 2019, 5:06am UTC](https://forum.ansible.com/t/how-to-escape-doublequote-and-curly-braces/30969/1 "2019-08-07T05:06:47Z")

</div>

i want to have an output as follows:

‘{“components”:“my\_variable”}’ from my playbook.

- name: Review the Joined List  
set\_fact:  
jetty\_c: “{{ ''{"\components”:“' + my\_joined\_list + '”}‘’ }}"

Its giving me error.  
Can you guys pls help.

---

<div class="post-metadata">

**Author:** ![racke](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/racke/32/4767_2.png) [@racke](https://forum.ansible.com/u/racke)\
**Post date:** [August 7, 2019, 5:39am UTC](https://forum.ansible.com/t/how-to-escape-doublequote-and-curly-braces/30969/2 "2019-08-07T05:39:00Z")

</div>

> i want to have an output as follows:
> 
> '{"components":"my\_variable"}' from my playbook.
> 
> - name: Review the Joined List  
> set\_fact:  
> jetty\_c: "{{ '\'{\"\components":"\' + my\_joined\_list + '"}'' }}"
> 
> Its giving me error.  
> Can you guys pls help.

What is the exact error? What are you trying to achieve ?

Regards  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Racke

---

<div class="post-metadata">

**Author:** ![Rakesh\_Parida](https://avatars.discourse-cdn.com/v4/letter/r/3ab097/32.png) [@Rakesh\_Parida](https://forum.ansible.com/u/Rakesh_Parida)\
**Post date:** [August 7, 2019, 6:23am UTC](https://forum.ansible.com/t/how-to-escape-doublequote-and-curly-braces/30969/3 "2019-08-07T06:23:37Z")

</div>

The value of my “my\_joined\_list”  
is : idp:25.0.1,das:25.0.0

Now i want my o/p to be as follows:

‘{“components”:“idp:25.0.1,das:25.0.0”}’

Error is as below

ERROR! Syntax Error while loading YAML.  
found unknown escape character

The error appears to be in ‘/root/raka-tests/raka-cac-components-parsing.yml’: line 145, column 29, but may  
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

set\_fact:  
jetty\_c: “{{ ''{"\components”:“' + my\_joined\_list }}”  
^ here  
We could be wrong, but this one looks like it might be an issue with  
missing quotes. Always quote template expression brackets when they  
start a value.

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [August 7, 2019, 8:15am UTC](https://forum.ansible.com/t/how-to-escape-doublequote-and-curly-braces/30969/4 "2019-08-07T08:15:52Z")

</div>

This should work

&nbsp;&nbsp;jetty\_c: '{{ {"components": my\_joined\_list} }}'

---

<div class="post-metadata">

**Author:** ![Rakesh\_Parida](https://avatars.discourse-cdn.com/v4/letter/r/3ab097/32.png) [@Rakesh\_Parida](https://forum.ansible.com/u/Rakesh_Parida)\
**Post date:** [August 7, 2019, 12:26pm UTC](https://forum.ansible.com/t/how-to-escape-doublequote-and-curly-braces/30969/5 "2019-08-07T12:26:09Z")

</div>

I was able to make it work:

jetty\_c: “‘{"components":"{{ my\_updated\_list}}"}’”

But now iam facing one more issue: i am trying to debug the contents to file but only the last item is getting appended

- name: Create Jetty Components  
set\_fact:  
jetty\_c: “‘{"components":"{{ my\_updated\_list }}"}’”  
with\_items: “{{ JETTY\_Record }}”

- name: Debug the Jetty Components  
debug:  
msg: “{{ jetty\_c }}”

What am i missing
