2013-07-01 42 views
0

我在下面的JSON對象上得到了「解析錯誤」。不知道如何解決它。解析帶有逗號和引號的JSON文本

{ 
    "Information": [ 
     { 
      "nm": "Earn Goody", 
      "st": "y", 
      "source": "Internet", 
      "story": [ 
       { 
"Don't let the smile fool you. Sabine Lisicki is the proverbial "crazy guy in the fight," at least when grass courts are involved. 
Perhaps the only player capable of keeping up with Serena Williams 
from a power-and-movement standpoint, Lisicki not only kept up, she 
beat Williams, 6-2, 1-6, 6-4, in the Round of 16 at Wimbledon on 
Monday.", 
"Women's tennis had, like men's tennis, grown predictable recently, with either Williams, Maria Sharapova, or Victoria Azarenka 
winning the last six slam titles." 
       } 
      ] 
     } 
    ] 
} 

結果:

{ 
    "Information": [ 
     { 
      "nm": "Earn Goody", 
      "st": "y", 
      "source": "Internet", 
      "story": [ 
       { 
        "Don't let the smile fool you. Sabine Lisicki is the proverbial crazyguyinthefight at least when grass courts are involved. Perhaps the only player capable of keeping up with Serena Williams from a power-and-movement standpoint, Lisicki not only kept up, she beat Williams, 6-2, 1-6, 6-4, in the Round of 16 at Wimbledon on Monday.", 
        "Women's tennis had, like men's tennis, grown predictable recently, with either Williams, Maria Sharapova, or Victoria Azarenka winning the last six slam titles." 
       } 
      ] 
     } 
    ] 
} 

Parse error on line 9: 
...imbledon on Monday.",     
-----------------------^ 
Expecting ':' 
+2

請求JSON供應商提供有效的JSON。 (當然,這可能是在複製/粘貼示例中,您以某種方式丟失了一個或兩個「\」或兩個)。 –

+0

您需要通過html代碼更改無效的caracter –

+0

未轉義的語音標記,JSON是破壞 - 他們需要在創建時逃脫 – Orbling

回答

1

的 「JSON」 數據串在Information[0]/story[0]包含轉義引號(")。這不是有效的JSON。

這裏的某個地方:。 。 。 proverbial "crazy guy in the fight," at least。 。 。

您的數據字符串中的引號應該轉義(\")。

像這樣:。 。 。 proverbial \"crazy guy in the fight,\" at least。 。 。

此外story[0] JSON對象包含沒有名稱的字段 - 也是無效的。你可以在大括號內放一個JSON字符串({ "abc" })。 JSON對象是鍵值對的集合,其鍵是JSON字符串({ "some-key": "abc" })。

一般情況下,參考這裏:http://json.org/

+0

謝謝你的工作。這工作:{ 「信息」:[ { 「nm」 是: 「賺取古迪」, 「ST」: 「Y」, 「源」: 「互聯網」, 「故事」:[ { 「NMA」: 「賺取古迪」, 「 p「:[ 」段落1「瘋子在戰鬥中」設置:6-2,1-6,6- 4,在16在溫網一輪星期一「, 」第2款的文字在這裏。「 ] } ] } ] } – Melon

1

你可能想的故事數組包含字符串值?在這種情況下,請移除數組內的捲曲「{}」。

引用的其他註釋也適用,但錯誤消息與無效數組格式有關。請參閱JSON.org