From 8c48366f1c2b184341ae1d0b9d62eb6bd0df506a Mon Sep 17 00:00:00 2001 From: Baptiste Mille-Mathias Date: Thu, 30 Jul 2020 21:45:40 +0200 Subject: [PATCH] Document to_json will convert to ASCII strings by default (#70954) ... as reported in issue #68702 --- .../rst/user_guide/playbooks_filters.rst | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/docs/docsite/rst/user_guide/playbooks_filters.rst b/docs/docsite/rst/user_guide/playbooks_filters.rst index 5e8b4a67950..4ee99db1aef 100644 --- a/docs/docsite/rst/user_guide/playbooks_filters.rst +++ b/docs/docsite/rst/user_guide/playbooks_filters.rst @@ -240,6 +240,24 @@ for example:: - set_fact: 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 To parse multi-document YAML strings, the ``from_yaml_all`` filter is provided.