A
A
Artem2016-12-05 20:29:53
PHP
Artem, 2016-12-05 20:29:53

Why does twig json_encode return {"?

Hello.
There is an array at the input:
Array
(
[1] => Moscow
[2] => St. Petersburg
[3] => Novosibirsk
[4] => Yekaterinburg
[5] => Nizhny Novgorod
[6] => Kazan
[7] = > Chelyabinsk
[8] => Omsk
[9] => Samara
[10] => Rostov-on-Don
[11] => Ufa
[12] => Krasnoyarsk
[13] => Perm
[14] => Voronezh
[15 ] => Volgograd
[16] => Krasnodar
[17] => Saratov
[18] => Tyumen
[19] => Togliatti
[20] => Izhevsk
[21] =>
[23] => Ulyanovsk
[24] => Khabarovsk
[25] => Yaroslavl
[26] => Makhachkala
[27] => Tomsk
[28] => Orenburg
[29] => Kemerovo
[30] => Novokuznetsk
[31 ] => Ryazan
[32] => Astrakhan
[33] => Naberezhnye Chelny
[34] => Penza
[35] => Lipetsk
[36] => Kirov
[37] => Tula
[38] => Cheboksary
[39] => Kaliningrad
[40] => Kursk
[41] => Ulan-Ude
[42] => Not selected
) Template
code:
let cities_info = {{ json|json_encode(constant('JSON_UNESCAPED_UNICODE')) }}
At the output I get this:
d491a75c79134cdbbf8916747d6727d4.png
How to avoid and what am I doing wrong?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Artem, 2016-12-05
@proudmore

let cities_info = {{ json|json_encode(constant('JSON_UNESCAPED_UNICODE'))|raw }}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question