blob: bedc18bab555ad1b8b077ed52a51dc7bab6550fd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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
|