Php json_encode不提供有效的json字符串

Php json_encode不提供有效的json字符串,php,json,Php,Json,我用json_encode生成的json字符串有这个问题。 这是输入: stdClass Object ( [titles] => stdClass Object ( [nl] => test [en] => test ) [contents] => stdClass Object ( [nl] => <p>\n test</p>\n [en] =&

我用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
    )

)
因此,我的json字符串无效。 这怎么可能?
我真的不知道我做错了什么。

啊!你说得对!愚蠢的我没有想到这一点,我总是为我的
SELECT
语句使用一个函数,在这段代码中我使用了
stripslashes()
,这显然使我的json字符串无效,因为其中有一些
\n
东西。
谢谢大家!

您所说的内容输出并不是
INSERT
语句存储在数据库中的值,但即使是有效的JSON也可以很好地解码。在你选择它之后,发布你的实际代码。此外,您可能应该规范化数据库模式,并停止在其中存储JSON。
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
)