我用 json_encode 生成的 json 字符串遇到了这个问题。这是输入:
stdClass Object
(
[titles] => stdClass Object
(
[nl] => test
[en] => test
)
[contents] => stdClass Object
(
[nl] => <p>\n test</p>\n
[en] => <p>\n test</p>\n
)
[languages] => stdClass Object
(
[0] => nl
[1] => en
)
)
我使用以下 SQL 语句将其放入我的数据库中:
INSERT INTO `pages`
(`title`, `content`, `lang`)
VALUES('{"nl":"test","en":"test"}', '{"nl":"<p>\\n\ttest<\/p>\\n","en":"<p>\\n\ttest<\/p>\\n"}', '{"0":"nl","1":"en"}')
据我所见,没有错,都存储在数据库中,没有问题。
然后我尝试获取我的内容的输出:
{"nl":"<p>n test</p>n","en":"<p>n test</p>n"}
这导致:
(
[id] => 10
[title] => stdClass Object
(
[nl] => test
[en] => test
)
[content] =>
[lang] => stdClass Object
(
[0] => nl
[1] => en
)
[created] => 2012-10-24 11:49:52
)
所以,我的 json 字符串是无效的。这怎么可能?我真的不知道我做错了什么。