laravel return json转码

直接返回json

return response()->json($data);

得到json,Unicode编码

[{"id":41,"name":"\u674e\u56db","date":"2020-10-04T16:00:00.000Z","affair":"\u7a7a\u8c03\u574f\u4e86","tag":"\u5df2\u5904\u7406"},{"id":45,"name":"135r","date":"2020-09-08T16:00:00.000Z","affair":"14","tag":"\u5df2\u5904\u7406"}]

设个编码

return response()->json($data)->setEncodingOptions(JSON_UNESCAPED_UNICODE);

得到json

[{"id":41,"name":"李四","date":"2020-10-04T16:00:00.000Z","affair":"空调坏了","tag":"已处理"},{"id":45,"name":"135r","date":"2020-09-08T16:00:00.000Z","affair":"14","tag":"已处理"}]
点赞

发表回复

邮箱不会被公开,用于显示Gravatar的头像