请问个json解析有关问题

WBOY
WBOYオリジナル
2016-06-13 10:11:01845ブラウズ

请教个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..……
声明:
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。