summaryrefslogtreecommitdiffstats
path: root/lib/ansible/plugins/filter/to_nice_json.yml
diff options
context:
space:
mode:
Diffstat (limited to 'lib/ansible/plugins/filter/to_nice_json.yml')
-rw-r--r--lib/ansible/plugins/filter/to_nice_json.yml54
1 files changed, 54 insertions, 0 deletions
diff --git a/lib/ansible/plugins/filter/to_nice_json.yml b/lib/ansible/plugins/filter/to_nice_json.yml
new file mode 100644
index 0000000..bedc18b
--- /dev/null
+++ b/lib/ansible/plugins/filter/to_nice_json.yml
@@ -0,0 +1,54 @@
+DOCUMENTATION:
+ name: to_nice_json
+ author: core team
+ version_added: 'historical'
+ short_description: Convert variable to 'nicely formatted' JSON string
+ description:
+ - Converts an Ansible variable into a 'nicely formatted' JSON string representation
+ - This filter functions as a wrapper to the Python C(json.dumps) function.
+ - Ansible automatically converts JSON strings into variable structures so this plugin is used to forcibly retain a JSON string.
+ options:
+ _input:
+ description: A variable or expression that returns a data structure.
+ type: raw
+ required: true
+ vault_to_text:
+ description: Toggle to either unvault a vault or create the JSON version of a vaulted object.
+ type: bool
+ default: True
+ version_added: '2.9'
+ preprocess_unsafe:
+ description: Toggle to represent unsafe values directly in JSON or create a unsafe object in JSON.
+ type: bool
+ default: True
+ version_added: '2.9'
+ allow_nan:
+ description: When C(False), strict adherence to float value limits of the JSON specification, so C(nan), C(inf) and C(-inf) values will produce errors.
+ When C(True), JavaScript equivalents will be used (C(NaN), C(Infinity), C(-Infinity)).
+ default: True
+ type: bool
+ check_circular:
+ description: Controls the usage of the internal circular reference detection, if off can result in overflow errors.
+ default: True
+ type: bool
+ ensure_ascii:
+ description: Escapes all non ASCII characters.
+ default: True
+ type: bool
+ skipkeys:
+ description: If C(True), keys that are not basic Python types will be skipped.
+ default: False
+ type: bool
+ notes:
+ - Both I(vault_to_text) and I(preprocess_unsafe) defaulted to C(False) between Ansible 2.9 and 2.12.
+ - 'These parameters to C(json.dumps) will be ignored, they are overriden for internal use: I(cls), I(default), I(indent), I(separators), I(sort_keys).'
+
+EXAMPLES: |
+ # dump variable in a template to create a nicely formatted JSON document
+ {{ docker_config|to_nice_json }}
+
+
+RETURN:
+ _value:
+ description: The 'nicely formatted' JSON serialized string representing the variable structure inputted.
+ type: string