请问个json解析有关问题

WBOY
發布: 2016-06-13 10:11:01
原創
828 人瀏覽過

请教个json解析问题
我有几个json串

HTML code
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->{"clusterno":167145108,"clustertype":1,"subid":"0","newperson":"欢迎【.dazuo.昵称.dayou.】来到群【.dazuo.群名.dayou.】.enter.信息:.enter..dazuo.信息.dayou..enter..dazuo.退群次数.dayou..enter.请改群名片:帮派名┃职位 或者 帮派名┃职位┃昵称.enter.名称不符.douhao.不改名者送去夏威夷...enter..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..enter.\.douhao.\是机器人.douhao.请直接无视忽略.","removeperson":"","expdatetime":"2021-10-18 23:50:42","userid":"1","username":"admin","updatecode":"7ECEDB4E1037476EAAF5FB5E8340AAEE"}
登入後複製


用json_decode解析会出现是null的.

我测试了 一下,是newperson这个接点太长导致的,有没有什么方法可以解决这个问题

------解决方案--------------------
反斜杠转义,转换编码
PHP code
<?php $json='{"clusterno":167145108,"clustertype":1,"subid":"0","newperson":"欢迎【.dazuo.昵称.dayou.】来到群【.dazuo.群名.dayou.】.enter.信息:.enter..dazuo.信息.dayou..enter..dazuo.退群次数.dayou..enter.请改群名片:帮派名┃职位 或者 帮派名┃职位┃昵称.enter.名称不符.douhao.不改名者送去夏威夷...enter..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..jhao..enter.\.douhao.\是机器人.douhao.请直接无视忽略.","removeperson":"","expdatetime":"2021-10-18 23:50:42","userid":"1","username":"admin","updatecode":"7ECEDB4E1037476EAAF5FB5E8340AAEE"}';$json=addcslashes($json,'\\');var_dump(json_decode(iconv('GBK','UTF-8',$json),true));?><br><font color="#e78608">------解决方案--------------------</font><br>utf-8编码文件就不需要再  iconv了.参考楼上的.<br><font color="#e78608">------解决方案--------------------</font><br>
登入後複製
探讨

反斜杠转义,转换编码
PHP code
$json='{"clusterno":167145108,"clustertype":1,"subid":"0","newperson":"欢迎【.dazuo.昵称.dayou.】来到群【.dazuo.群名.dayou.】.enter.信息:.enter..dazuo.信息.dayou..enter..dazuo.退群次数.dayou..……
相關標籤:
來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板