Home > Backend Development > PHP Tutorial > 请教这个字符串为什么不能json_decode

请教这个字符串为什么不能json_decode

WBOY
Release: 2016-06-23 13:58:29
Original
768 people have browsed it

[{"desc":"1111","imgurl":"./data/attachments/20140422/5355e745ae166.jpg"},{"desc":"333333","imgurl":"./data/attachments/20140422/5355e745c8a40.jpg"},{"desc":"u306e333","imgurl":"./data/attachments/201
Copy after login


数据先是json_encode 存入数据库 但是从数据库取出来 json_decode 返回NULL

后来尝试使用serialize把数据存入数据库 从数据库取出来unserialize 返回 bool(false)

存入数据库 或者 从数据库取出来都是在同一个文件里操作 应该不存在编码的问题,请教一下可能是什么原因


回复讨论(解决方案)

字符串不全,少” ] }

[    {        "desc": "1111",        "imgurl": "./data/attachments/20140422/5355e745ae166.jpg"    },    {        "desc": "333333",        "imgurl": "./data/attachments/20140422/5355e745c8a40.jpg"    },    {        "desc": "u306e333",        "imgurl": "./data/attachments/201"    }]
Copy after login

还有就是你数据库字段长度不足吧

手误还是确实截断了?

贴出从数据库取出来的数据

贴出 存入json数据的字段的属性?字段是否被截断。

  的确是数据库字段设置的太短  给截断了,谢谢大家的热心帮忙

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