# How to prevent ansible to suppress escaped quotes?

**URL:** <https://forum.ansible.com/t/how-to-prevent-ansible-to-suppress-escaped-quotes/35653>\
**Category:** Ansible Project\
**Created:** [August 20, 2021, 2:46pm UTC](https://forum.ansible.com/t/how-to-prevent-ansible-to-suppress-escaped-quotes/35653 "2021-08-20T14:46:55Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gaetan\_QUENTIN](https://avatars.discourse-cdn.com/v4/letter/g/e9bcb4/32.png) [@Gaetan\_QUENTIN](https://forum.ansible.com/u/Gaetan_QUENTIN)\
**Post date:** [August 20, 2021, 2:46pm UTC](https://forum.ansible.com/t/how-to-prevent-ansible-to-suppress-escaped-quotes/35653/1 "2021-08-20T14:46:55Z")

</div>

Hi,

in a json file we have this escaped quoted part:

{

inputs: {

```
&quot;value&quot;: &quot;my \\&quot; value \\&quot; is here&quot;

```

[..]

this json file is read from extra var at command line: -e "@inputs.json"

then a template jinja use it and create another json file . The j2 template use {{ inputs.value }} which become: "my value is here"

-\> protected quotes have disappeared, which make our final system to hang.

How to prevent this?

Regards

---

<div class="post-metadata">

**Author:** ![felixfontein](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/felixfontein/32/7530_2.png) [@felixfontein](https://forum.ansible.com/u/felixfontein)\
**Post date:** [August 20, 2021, 3:13pm UTC](https://forum.ansible.com/t/how-to-prevent-ansible-to-suppress-escaped-quotes/35653/2 "2021-08-20T15:13:43Z")

</div>

Hi,

I tried to replicate this, but without success. The quotes were there.  
So you probably have to provide more information.

> {
> 
> inputs: {
> 
> ```
> &quot;value&quot;: &quot;my \\&quot; value \\&quot; is here&quot;
> 
> ```
> 
> [..]

Please note that it must be "inputs" for a proper JSON file. Also  
please note that the "value" line you inserted above contains some  
special invisible characters that trip up both JSON and YAML parsers.

Cheers,  
Felix

---

<div class="post-metadata">

**Author:** ![Gaetan\_QUENTIN](https://avatars.discourse-cdn.com/v4/letter/g/e9bcb4/32.png) [@Gaetan\_QUENTIN](https://forum.ansible.com/u/Gaetan_QUENTIN)\
**Post date:** [August 23, 2021, 10:32am UTC](https://forum.ansible.com/t/how-to-prevent-ansible-to-suppress-escaped-quotes/35653/3 "2021-08-23T10:32:39Z")

</div>

Sorry i have simplified too much my example.  
Here is the whole thing:

inputs\_with\_escaped\_quotes.json :

{

“inputs”: {

“value”: “this is a " escaped quoted " " string " yeah…”

}

}

Tasks :

Escaped\_quotes.yml :

---

<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 23, 2021, 10:37am UTC](https://forum.ansible.com/t/how-to-prevent-ansible-to-suppress-escaped-quotes/35653/4 "2021-08-23T10:37:39Z")

</div>

> Sorry i have simplified too much my example.  
> Here is the whole thing:

Using templates for structured data like XML and JSON is a bad idea in most cases (IMHO).

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

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [August 23, 2021, 11:16am UTC](https://forum.ansible.com/t/how-to-prevent-ansible-to-suppress-escaped-quotes/35653/5 "2021-08-23T11:16:26Z")

</div>

Yup.  
I would suggest from\_json and to\_json etc.

---

<div class="post-metadata">

**Author:** ![Gaetan\_QUENTIN](https://avatars.discourse-cdn.com/v4/letter/g/e9bcb4/32.png) [@Gaetan\_QUENTIN](https://forum.ansible.com/u/Gaetan_QUENTIN)\
**Post date:** [August 23, 2021, 12:09pm UTC](https://forum.ansible.com/t/how-to-prevent-ansible-to-suppress-escaped-quotes/35653/6 "2021-08-23T12:09:49Z")

</div>

hi,

the inputs are read from extra variable : -e “@inputs.json”. So they are already turned into dict. Not enough?

Regards  
Gaétan

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [August 23, 2021, 2:09pm UTC](https://forum.ansible.com/t/how-to-prevent-ansible-to-suppress-escaped-quotes/35653/7 "2021-08-23T14:09:57Z")

</div>

your `jsoncode` is a misnomer at that point since it will  
automatically transform into a python structure internally, use
