Home > Backend Development > PHP Tutorial > php的json接口转码问题?不知道哪里错误了弄出来都是乱码

php的json接口转码问题?不知道哪里错误了弄出来都是乱码

WBOY
Release: 2016-06-06 20:15:56
Original
881 people have browsed it

<code>{"appid":"assdf","appsecret":"56d0626167e58ee3770021b6","itemdata":{"nType":"1","nBaoYou":"0","szItemId":"520361590788","title":"韩版夏季韩国大码无袖T恤宽松短裤女休闲学生跑步运动套装两件套","secondTitle":"","imgURL":"http:\/\/img4.tbcdn.cn\/tfscom\/i1\/TB1wJnVIpXXXXcHXFXXXXXXXXXX_!!0-item_pic.jpg","promotionTxt":"继续狂欢节","fOldPrice":"58","fThirdPrice":"19.9","fCommissionPer":"12.3","fCommission":"2.45","nTgCount":"1","nSellCount":"-1","fPingFen":"-1","nPingjiaCount":"-1","szTgURL":"http:\/\/s.click.taobao.com\/NT7PEcx","szWebTgURL":"","szBlogTgURL":"","shortUrl":"http:\/\/s.click.taobao.com\/NT7PEcx","szDesc":""}\r\n}
</code>
Copy after login
Copy after login

这个是在PHP端ECHO 出来的.但是变成这样?不知道哪里解码错误了,中文给解码出来了,但是引号好像变成了其他东西,思路比较模糊,希望做过的人给个清晰的思路

回复内容:

<code>{"appid":"assdf","appsecret":"56d0626167e58ee3770021b6","itemdata":{"nType":"1","nBaoYou":"0","szItemId":"520361590788","title":"韩版夏季韩国大码无袖T恤宽松短裤女休闲学生跑步运动套装两件套","secondTitle":"","imgURL":"http:\/\/img4.tbcdn.cn\/tfscom\/i1\/TB1wJnVIpXXXXcHXFXXXXXXXXXX_!!0-item_pic.jpg","promotionTxt":"继续狂欢节","fOldPrice":"58","fThirdPrice":"19.9","fCommissionPer":"12.3","fCommission":"2.45","nTgCount":"1","nSellCount":"-1","fPingFen":"-1","nPingjiaCount":"-1","szTgURL":"http:\/\/s.click.taobao.com\/NT7PEcx","szWebTgURL":"","szBlogTgURL":"","shortUrl":"http:\/\/s.click.taobao.com\/NT7PEcx","szDesc":""}\r\n}
</code>
Copy after login
Copy after login

这个是在PHP端ECHO 出来的.但是变成这样?不知道哪里解码错误了,中文给解码出来了,但是引号好像变成了其他东西,思路比较模糊,希望做过的人给个清晰的思路

json_encode添加第二个参数,JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_UNICODE,所有的转义和中文字符就可以保持不变

是用的json_encode()函数把数组转成json么?

只是另外吧双引号 转成了'& quot;'

你在json_encode后才进行符号转义
应该在数组时就进行内容的转义,然后json_encode

json_encode 之前的数据什么样子的?

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template