How to prevent ansible to suppress escaped quotes?

Hi,

in a json file we have this escaped quoted part:

{

inputs: {

"value": "my \\" value \\" is here"

[ .. ]

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

Hi,

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

{

inputs: {

"value": "my \\" value \\" is here"

[ .. ]

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

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 :

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
        Racke

Yup.
I would suggest from_json and to_json etc.

hi,

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

Regards
Gaétan

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