I created a twig array and populated it with objects, and i want to parse that to an javascript array and objects
Twig array:
itm = array:1 [
0 => array:2 [
"Test1" => "Testtt1"
"Test2" => "Testtt2"
]
]
I tried to parse it like this but it return and empty array:
var arrAll = [];
arrAll = {{ itm|json_encode }}
You have to get the raw variable, otherwise it will fail:
var arrAll = [];
arrAll = {{ itm|json_encode|raw }}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.