为什么以下JSON无效?

时间:2011-06-09 06:31:10

标签: json

以下JSON未通过验证。验证器以"Can an officer...

开头的第一个字符串值进行投诉

它看起来像是键的有效字符串值的开头。究竟是什么问题呢?

{
   "DUI": {
      "Can an officer arrest me because he smelled alcohol on my breath?":"<br />No, odor alone is not sufficient basis for arrest. However, odor combined with other observations such as weaving, slurred speech, and bloodshot eyes 
may be enough to give an officer probable cause to arrest you for DUI.",
      "Can I be convicted if I refused to take the breath test or the result was below .08?":"<br />Yes, in Washington the prosecutor can prove DUI one of two ways: 1. Blood or breath test result above .08, OR  2. Proof the person was under the 
influence of or affected by liquor or drugs.
<br /><br />Additionally, if a person refused to take a test, that fact may be introduced as evidence at trial.",
      "How can I be arrested if I wasn't driving my car?":"<br />A person who is in physical control of a vehicle and appears to be under the influence of drugs or alcohol may be arrested and charged under RCW 
46.61.504.",
      "What can I do now that I have been charged?":"<br />Contact an attorney to find out what options are available to you."
   }
}

1 个答案:

答案 0 :(得分:5)

似乎不喜欢粘贴的JSON中存在一些换行符:

Parse error on line 3:
...ohol on my breath?":"<br />No, odor alon
-----------------------^
Expecting 'STRING', 'NUMBER', 'NULL', 'TRUE', 'FALSE', '{', '['

我将你的问题中的JSON粘贴到验证器中并删除了不必要的换行符 - 这有效:

{
    "DUI": {
        "Can an officer arrest me because he smelled alcohol on my breath?": "<br />No, odor alone is not sufficient basis for arrest. However, odor combined with other observations such as weaving, slurred speech, and bloodshot eyes may be enough to give an officer probable cause to arrest you for DUI.",
        "Can I be convicted if I refused to take the breath test or the result was below .08?": "<br />Yes, in Washington the prosecutor can prove DUI one of two ways: 1. Blood or breath test result above .08, OR  2. Proof the person was under the influence of or affected by liquor or drugs.<br /><br />Additionally, if a person refused to take a test, that fact may be introduced as evidence at trial.",
        "How can I be arrested if I wasn't driving my car?": "<br />A person who is in physical control of a vehicle and appears to be under the influence of drugs or alcohol may be arrested and charged under RCW 46.61.504.",
        "What can I do now that I have been charged?": "<br />Contact an attorney to find out what options are available to you."
    }
}

http://jsonlint.com/