Home > Backend Development > PHP Tutorial > 数据库取出来的json问题

数据库取出来的json问题

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-23 13:42:21
Original
955 people have browsed it


我把一段JOSN代码存在数据库存的一个字段里,但存进后双引号都转义了。
像这样

[{"id":"9","model":"A2","quantity":1}]
Copy after login


读到html上也是这样显示了,不会有引号。
请问怎么样才可以把它转成json代码。


回复讨论(解决方案)

[{"id":"9","model":"A2","quantity":1},{"id":"8","model":"A1","quantity":1}]
Copy after login


原本应该是这样的。

$s = ‘[{"id":"9","model":"A2","quantity":1}]’;echo html_entity_decode(html_entity_decode($s));
Copy after login
[{"id":"9","model":"A2","quantity":1}]

你自己在入库时自作多情的做了 htmlentities 编码转换,很自然就不能直接使用了

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