将字符串解析为JSON对象时出现意外的非空白错误

时间:2016-04-30 04:39:32

标签: jquery json parsing

我的字符串是

"\"{'Body': '<p>I have a issue : When I add a content that includes text and hyperlink, after that I use the wrapLongStringIntoMultiLine to set length of each lines. But in the special case, the end of line is in scope of hyperlink, so the hyperlink structure is broken. \\r\\r\\nHere is my code :</p>\\r\\r\\n\\r\\r\\n<pre><code>String languages=\"\" Deutsch, English (All), English (United Kingdom), Bahasa Indonesia, Italiano &lt;a href=\\\\\"\"\\\\\"\"&gt;  edit&lt;/a&gt;\"\";\\r\\r\\n</code></pre>\\r\\r\\n\\r\\r\\n<p>after call wrapLongStringIntoMultiLine: </p>\\r\\r\\n\\r\\r\\n<pre><code>&lt;html&gt;Deutsch, English (All), English (United Kingdom),&lt;/br&gt; Bahasa Indonesia, Italiano &lt;a href&lt;br&gt;=\\\\\"\"\\\\\"\"&gt;  edit&lt;/a&gt;\"\";\\r\\r\\n</code></pre>\\r\\r\\n\\r\\r\\n<p>The <code>&lt;br&gt; tag</code> exists in the scope of hyperlink. How to fix this issue? Please give me advise. Thanks</p>\\r\\r\\n', 'Title': 'Use the wrapLongStringIntoMultiLine on the Jeditor pane'}\"\r"

我已经使用JSON LINt验证了字符串,并将其显示为有效的JSON。

SyntaxError: JSON.parse: unexpected non-whitespace character afterJSON data at line 1 column 338 of the JSON data

当我使用$ .parseJSON(str)

时,这是我得到的错误

1 个答案:

答案 0 :(得分:0)

根据我的观察,我发现,有&#34; :&#34;在你的字符串中,所以 json 无法理解那个特定的东西,让我们在你的字符串中说,

I have a issue : When I add a content...

所以我建议你试试&#34; - &#34;而不是&#34; :&#34;

例如,

I have a issue - When I add a content...