ansible.builtin.from_json filter – Convert JSON string into variable structure
Note
This filter plugin is part of ansible-core and included in all Ansible
installations. In most cases, you can use the short
plugin name
from_json.
However, we recommend you use the Fully Qualified Collection Name (FQCN) ansible.builtin.from_json for easy linking to the
plugin documentation and to avoid conflicting with other collections that may have
the same filter plugin name.
Synopsis
Converts a JSON string representation into an equivalent structured Ansible variable.
Ansible automatically converts JSON strings into variable structures in most contexts, use this plugin in contexts where automatic conversion does not happen.
Input
This describes the input of the filter, the value before | ansible.builtin.from_json.
Parameter |
Comments |
|---|---|
A JSON string. |
Notes
Note
This filter functions as a wrapper to the Python
json.loadsfunction.
Examples
# variable from string variable containing a JSON document
{{ docker_config | from_json }}
# variable from string JSON document
{{ '{"a": true, "b": 54, "c": [1,2,3]}' | from_json }}
Return Value
Key |
Description |
|---|---|
The variable resulting from deserialization of the JSON document. Returned: success |