Yup.
I would suggest from_json and to_json etc.

On Mon, 23 Aug 2021 at 12:38, Stefan Hornburg (Racke) <[email protected]> wrote:
>
> On 23/08/2021 12:32, Gaétan QUENTIN wrote:
> > 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
>
> > inputs_with_escaped_quotes.json :
> >
> > {
> >
> >      "inputs": {
> >
> >          "value": "this is a \" escaped quoted \"  \" string \"  yeah..."
> >
> >      }
> >
> > }
> >
> > Tasks :
> >
> > Escaped_quotes.yml :
> >
> > ---
> >
> > - name: escaped quotes set_fact
> >
> >    set_fact:
> >
> >      jsoncode: "{{ lookup('template', 'template_with_escaped_quotes.j2') }}"
> >
> > - name: Save file
> >
> >    local_action:
> >
> >      module: copy
> >
> >      content: "{{ jsoncode }}"
> >
> >      dest: "{{ role_path }}/files/output.json"
> >
> > Templates  template_with_escaped_quotes.j2:
> >
> > {
> >
> >      "result_value": "{{ inputs.value }}"
> >
> > }
> >
> > Json result : output.json :
> >
> > {
> >
> >      "result_value": "this is a " escaped quoted "  " string "  yeah..."
> >
> > }
> >
> >
> >
> > Regards
> > Le vendredi 20 août 2021 à 17:14:00 UTC+2, Felix Fontein a écrit :
> >
> >     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
> >
> > --
> > You received this message because you are subscribed to the Google Groups 
> > "Ansible Project" group.
> > To unsubscribe from this group and stop receiving emails from it, send an 
> > email to [email protected] 
> > <mailto:[email protected]>.
> > To view this discussion on the web visit 
> > https://groups.google.com/d/msgid/ansible-project/e542a036-a0e6-44f8-a1f7-2111a25bb703n%40googlegroups.com
> >  
> > <https://groups.google.com/d/msgid/ansible-project/e542a036-a0e6-44f8-a1f7-2111a25bb703n%40googlegroups.com?utm_medium=email&utm_source=footer>.
>
>
> --
> Ecommerce and Linux consulting + Perl and web application programming.
> Debian and Sympa administration.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/ansible-project/f6e14f98-55b1-aa2c-1138-235ea05a627e%40linuxia.de.
>


-- 
Dick Visser
Trust & Identity Service Operations Manager
GÉANT

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAL8fbwNQh%3DUn4m89monjNwpbF99ycPBo7L2%3DsWSXfiMktAowGw%40mail.gmail.com.

Reply via email to