Json_encode returns & quot;

I am trying to build a chart with Chart.js using laravel. The json_encode function returns a string with and quot; instead of "that Chart.js cannot recognize. Tried htmlspecialchars_decode () with no luck. Is there any other workaround? Please help.

This is the laravel code

labels: {{ htmlspecialchars_decode(json_encode($sm_names)) }}, datasets: [{ data: {{ str_replace('"','',json_encode($sm_totals))}}, 

and so it is displayed in javascript:

 labels: ["John","Mercy ","Gary"], datasets: [{ data: [425000,470000,10000], 
+5
source share
1 answer

If you use a blade, try {!! json_encode($sm_names) !!} {!! json_encode($sm_names) !!}

+20
source

Source: https://habr.com/ru/post/1237086/


All Articles