Skip to content

from_json

Collection Note

This module is part of the ansible.builtin collection. To install the collection, use:

ansible-galaxy collection install ansible.builtin
Added in version historical.

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.

Parameters

Parameter Defaults / Choices Comments
_input
string
required
A JSON string.

Notes

Note

  • This filter functions as a wrapper to the Python C(json.loads) function.

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 Values

Key Data Type Description Returned
_value raw The variable resulting from deserialization of the JSON document.