请问个json解析有关问题

WBOY
Release: 2016-06-13 13:46:15
Original
909 people have browsed it

请教个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"}
Copy after login


用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>
Copy after login
探讨

反斜杠转义,转换编码
PHP code
$json='{"clusterno":167145108,"clustertype":1,"subid":"0","newperson":"欢迎【.dazuo.昵称.dayou.】来到群【.dazuo.群名.dayou.】.enter.信息:.enter..dazuo.信息.dayou..enter..dazuo.退群次数.dayou..……
Related labels:
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