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

SwissNight's avatar

Blade destroys json object passed to vue.js when it contains whitespaces

Hi all,

I have a json object containing (see the whitepace after Accept_):

{[
        "id" => 1
        "text" => "Accept_ _TODO"
]}

I then give it to vue in a blade file:

<example :rowsfromdatabase={{ $rowsFromPHP }}></example>

And I get the error:

[Vue warn]: Error compiling template:

<div id="app">
          <example :rowsfromdatabase="[{&quot;id&quot;:1,&quot;text&quot;:&quot;Accept_" _todo&quot;}]=""></example>
        </div>

- invalid expression: :rowsfromdatabase="[{"id":1,"key":"claim_config_step_action_accept_claim","text":"Accept_"


(found in <Root>)

Blade (or someone :) ) sends "Accept_" rather than "Accept_ _TODO"}]. Anything I can do? I tried {{{ or {!! instead of {{ but it doesn't work.

0 likes
3 replies
SwissNight's avatar

So, for some obscure reason, it works with

<example :rowsfromdatabase="{{ $rowsFromPHP }}"></example>

If any one can explain why the added quotes solve the problem, I'd be thrilled :).

kfirba's avatar
kfirba
Best Answer
Level 50

@SwissNight This is how vue works. You need the double-quotes since you can also pass an expression as an argument. For example:

<example :some-key="3+4"></example>

In the above case, the value of someKey will be 7 and not the string 3+4.

Please or to participate in this conversation.