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

数据库取出来的json问题

WBOY
WBOYOriginal
2016-06-23 13:42:21930browse


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

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


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


回复讨论(解决方案)

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


原本应该是这样的。 

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

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

Statement:
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
Previous article:php正则替换Next article:discuz帖子编辑后存入数据库