Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Laravel @json in blade is giving coded result, but dump is correct

Hello and welcome my Dear friends, I am not posting very often but I am dying from the pain of current problem I have encountered.

I am attaching pictures, but in short array that is created for JSON output in my recruitment page is giving coded outcome which looks like ‘\u3010\u5510\u6d25\u99c5\u3011\u226a\u5b8c\u5168’ in all JSON elements.

I have tried to make mb_encode_check and it returns UTF-8 everywhere. In database coding is utf8_general_ci so it is not a problem.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I also have tried to encode it many times with utf8_decode/encode, json_endcode/decode and others without a success.

Please share with me your wisdom.

Controller passing results screen

Debug outcome

Blade calling place

Output in source

>Solution :

Have you tried the JSON_UNESCAPED_UNICODE flag?

<?= json_encode($page_data->json, JSON_UNESCAPED_UNICODE) ?>

If you don’t want to escape slashes either, that would be the JSON_UNESCAPED_SLASHES flag:

<?= json_encode($page_data->json, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) ?>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading