filter_from_json (zotonic_mod_base v1.0.0-rc.17)
Parse a string as a JSON (JavaScript Object Notation) value. The returned value can be processed futher.
For example:
{{ "[1,2,3]"|from_json|first }}Converts this JSON string to a list of integers and displays the first result:
1Another example with a string that parses to a structured value:
{% with '{ "a": "Hello", "b": 2 }'|from_json as obj %}
{% print obj.a %}
{% endwith %}This will display:
HelloIf the given value can not be parsed as JSON then it is silently mapped to undefined.