Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

SteveBelanger's avatar

from json to javascript in blade

I want to pass a variable to javascript, from Blade my variable does have the correct format : [{"keyA":"ValueA"},{"keyB":"valueB"},{etc.}]

then, I do this var myVariable = {{$myVariable}} this does: myVariable = [{AndQuot;keyAAndQuot; ...etc. }] (htmlentities)

so I do this: var myVariable = {{!!$myVariable!!}} and curly braces get added : var myVariable = {[{"keyA":"ValueA"},{"keyB":"valueB"},{etc.}]}

there must be something simple to do, that I am just missing...

0 likes
2 replies
lostdreamer_nl's avatar
Level 53

Try using {!! !!} ( note the single { with 2 ! )

3 likes

Please or to participate in this conversation.