I'm facing an issue when use PHP json_encode
function. Sometimes, the encoded JSON lost }
bracket at the end of JSON, but sometimes it's not.
The PHP code:
$json = json_encode([
'type' => 'news',
'status' => $status, // string
'data' => $news, // array of data
], JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES);
The data contains Chinese characters. I used fetch
on JS to request the JSON and when it parsed the JSON, it returned a parse error
message as unexpected end of JSON input
.
Here's what does the JSON looks like:
What's going wrong here???