Converts a JSON-string into an associative array.
Basically this wraps the PHP-function json_decode().
Syntax
json_decode(mixed $str, bool $assoc = true): mixed
Parameter
- $str The JSON-string to decode.
- $assoc If TRUE, returned objects will be converted into associative arrays.
Return
Returns the (associative) array from $str.
If $str was not a string, then $str itself is returned.
Example
{# A hardcoded JSON-string is converted into a twig-var: "myArr" #} {% set myArr = hublify.json_decode( '{ "aVar": "hello world!" }' ) %}