Php JSON解码崩溃

Php JSON解码崩溃,php,json,Php,Json,我正在从富文本区检索文本,并尝试输入json。 我有这样一个json: {"content":"<p>Mauritian politics is vibrant and characterised by several problems. Some of them are coalition...","title":"sdddddddddddddddddddddddddddddddddddddddddddddd","interestId":"11","commentType":"P

我正在从富文本区检索文本,并尝试输入json。 我有这样一个json:

{"content":"<p>Mauritian politics is vibrant and characterised by several problems. 
Some of them are coalition...","title":"sdddddddddddddddddddddddddddddddddddddddddddddd","interestId":"11","commentType":"Post"}
{“content”:“毛里求斯政治充满活力,存在一些问题。
其中一些是联盟…,“标题”:“SDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD
现在,当我试图用php解析上面的json时,它没有给我一个空json

我知道问题是什么,问题是‘几个问题’后面的空格。因为我解析这个,所以没问题

{"content":"<p>Mauritian politics is vibrant and characterised by severak problems.Some of them are coalition...","title":"sdddddddddddddddddddddddddddddddddddddddddddddd","interestId":"11","commentType":"Post"}
{“内容”:“毛里求斯政治充满活力,并以几个问题为特征。其中一些问题是联盟……”,“标题”:“SDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD
由于新行,json_decode()失败。要在JSON中嵌入新行,请使用“\n”。例如:


这不是空格,这是回车,把它从字符串中去掉,你会没事的。如果要保留多余的行,请使用nl2br()。内容来自HTML,例如,用户可以复制整个页面并将其粘贴到富格文本区域。然后我要做的是获取HTML,为它构建一个json,并将其发送到RESTAPI,在那里它将保存为用户注释。在这种情况下,我建议不要手动构建json,而是在PHP数组上使用json_encode(),如上面的示例所示。这样,您将确保您将拥有有效的JSON。
<?php
$a = 'test
test
cheese';

echo json_encode(array($a));
?>
["test\ntest\ncheese"]