title: laravel get data to pass to laravel blade but in json format
body: <p>I have data that I am creating a chart using d3.js.  I have that part working with hard coding the data as such</p>
  
  <pre><code>var data = {
              "name": ["A", "B", "C", "D", "E"],
              "vals": [48, 35, 34, 21, 11]
          }
  </code></pre>
  
  <p>Where I am struggling is to get data into the javascript section of my blade template.  I have tried to hardcode the following and I get an htmlspecialchars() expects parameter 1 to be string, object given.  </p>
  
  <pre><code>$test = json_encode([
              "name" =&gt; ["A", "B", "C", "D", "E"],
              "vals"=&gt; [48, 35, 34, 21, 11]
          ]);
  </code></pre>
  
  <p>with this in the script area of the blade</p>
  
  <pre><code>var test = {{json_decode($test)}};
  </code></pre>
  
  <p>If I don't do json_decode I don't get an error but it transforms my " to &amp;quot which obviously won't work.</p>
  
  <p>I know I am just missing something here to make it work but maybe I will just do a new method and do an ajax call to get it.</p>
  
  <p>Any thoughts or tips would be helpful</p>