Document to_json will convert to ASCII strings by default (#70954)

... as reported in issue #68702
This commit is contained in:
Baptiste Mille-Mathias 2020-07-30 21:45:40 +02:00 committed by GitHub
parent e28b20d729
commit 8c48366f1c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -240,6 +240,24 @@ for example::
- set_fact: - set_fact:
myvar: "{{ result.stdout | from_json }}" myvar: "{{ result.stdout | from_json }}"
Filter `to_json` and Unicode support
------------------------------------
By default `to_json` and `to_nice_json` will convert data received to ASCII, so::
{{ 'München'| to_json }}
will return::
'M\u00fcnchen'
To keep Unicode characters, pass the parameter `ensure_ascii=False` to the filter::
{{ 'München'| to_json(ensure_ascii=False) }}
'München'
.. versionadded:: 2.7 .. versionadded:: 2.7
To parse multi-document YAML strings, the ``from_yaml_all`` filter is provided. To parse multi-document YAML strings, the ``from_yaml_all`` filter is provided.