php开发-无法解析json
问题描述: 无法解析回调的json数据,json_decode() 函数返回null,接收的数据直接放postman 中解析正常
file_get_contents(‘php://input’)接收到就有乱码
1 | $HEX="7b2273657269616c4e756d626572223a22323032353132323331373330333539333" |
1 | {"serialNumber":"2025122317303593751B","orderId":"FLOW0012000100251223173046814154","status":-1,"message":"E<1%?^C^Z?^ZE<1%(failed)","voucher":"failed"} |
解决方法:
有换行符之类POSIX字符造成的
最终问题可能在php接收前,那边被转码造成的,因为php端接收到就是乱码了
1 | $converted = mb_convert_encoding($content, 'UTF-8', "UTF-8"); |