Laravel @json Directive

On the blade side, you can use this directive to convert arrays or objects to json.

<script>
    let data = @json(['name' => 'PHPEXAMPLE', 'surname' => 'NET']);
</script>

Or it can be in a variable defined by the controller, of course this;

<script>
    let data = @json($user);
</script>
Comments

There are no comments, make the firs comment