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

Time:08-04

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.

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

CodePudding user response:

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) ?>
  • Related