我有一個問題讓我目前瘋狂。通過JQuery,我從服務器請求一個JSON文檔,該文檔不被接受(錯誤是「意外字符」)。然而,我的JSON文件似乎很好,在Firebug中,即JSON數據被正確檢測和解析。JQuery不接受JSON有效
如果我複製響應並嘗試通過jsonlint.com進行驗證,它始終會在第一個字符([
)上失敗。如果我更改了某些字符並複製了其他內容,但保留了相同的結果(例如,請嘗試複製[]
的內容,然後再擦除它們並再次寫入,再次粘貼內容並且您具有相同的文檔,但它現在可以驗證)。奇怪。所以我認爲它可能與編碼有關,但Firefox明確指出,一切都是UTF8編碼。
現在我有點不知所措,我希望你能以任何方式幫助我。
這裏是我的服務器的JSON的回覆:
[
{
"id": 67,
"startdate": "01.01.1970 01:00:00",
"hometeam": "EHC Muskrats",
"awayteam": "EHC Vienna Wookies"
} , {
"id": 69,
"startdate": "01.01.1970 01:00:00",
"hometeam": "EC Mammuts",
"awayteam": "EHC Vienna Wookies"
} , {
"id": 70,
"startdate": "01.01.1970 01:00:00",
"hometeam": "EHC Vienna Wookies",
"awayteam": "EC Mammuts"
} , {
"id": 86,
"startdate": "01.01.1970 01:00:00",
"hometeam": "EHC Vienna Wookies",
"awayteam": "EC Mammuts"
} , {
"id": 4,
"startdate": "08.10.2012 21:00:00",
"hometeam": "Wiener Teifl",
"awayteam": "EHC Vienna Wookies"
} , {
"id": 18,
"startdate": "28.10.2012 21:00:00",
"hometeam": "EC Heizbären",
"awayteam": "EHC Vienna Wookies"
} , {
"id": 19,
"startdate": "04.11.2012 18:00:00",
"hometeam": "EHC Vienna Wookies",
"awayteam": "Innviertel Penguins"
} , {
"id": 6,
"startdate": "15.11.2012 21:00:00",
"hometeam": "EHC Vienna Wookies",
"awayteam": "EC Heizbären"
} , {
"id": 62,
"startdate": "17.11.2012 19:30:00",
"hometeam": "EC V.U. Totonka",
"awayteam": "EHC Vienna Wookies"
} , {
"id": 12,
"startdate": "22.11.2012 20:30:00",
"hometeam": "EHC Vienna Wookies",
"awayteam": "EHC Muskrats"
} , {
"id": 13,
"startdate": "27.11.2012 19:30:00",
"hometeam": "TÜV Cannibals",
"awayteam": "EHC Vienna Wookies"
} , {
"id": 7,
"startdate": "02.12.2012 17:00:00",
"hometeam": "Fire Fighters jun.",
"awayteam": "EHC Vienna Wookies"
} , {
"id": 63,
"startdate": "03.12.2012 19:00:00",
"hometeam": "",
"awayteam": "EHC Vienna Wookies"
} , {
"id": 8,
"startdate": "09.12.2012 17:00:00",
"hometeam": "EHC Vienna Flames",
"awayteam": "EHC Vienna Wookies"
} , {
"id": 14,
"startdate": "17.12.2012 20:15:00",
"hometeam": "EC Mammuts",
"awayteam": "EHC Vienna Wookies"
} , {
"id": 15,
"startdate": "07.01.2013 20:15:00",
"hometeam": "EHC Vienna Wookies",
"awayteam": "EC Mammuts"
} , {
"id": 9,
"startdate": "10.01.2013 20:00:00",
"hometeam": "EHC Vienna Wookies",
"awayteam": "EHC Chiefs"
} , {
"id": 11,
"startdate": "19.01.2013 21:00:00",
"hometeam": "EC Attacki",
"awayteam": "EHC Vienna Wookies"
} , {
"id": 16,
"startdate": "24.01.2013 20:30:00",
"hometeam": "EHC Vienna Wookies",
"awayteam": "TÜV Cannibals"
} , {
"id": 10,
"startdate": "28.01.2013 19:30:00",
"hometeam": "EHC Vienna Wookies",
"awayteam": "EC V.U. Totonka"
} , {
"id": 17,
"startdate": "30.01.2013 20:30:00",
"hometeam": "EHC Muskrats",
"awayteam": "EHC Vienna Wookies"
} , {
"id": 65,
"startdate": "24.02.2013 21:00:00",
"hometeam": "EC Heizbären",
"awayteam": "EHC Vienna Wookies"
} , {
"id": 66,
"startdate": "28.02.2013 20:40:00",
"hometeam": "EHC Vienna Wookies",
"awayteam": "EHC Chiefs"
} , {
"id": 64,
"startdate": "08.03.2013 21:00:00",
"hometeam": "EHC Vienna Flames",
"awayteam": "EHC Vienna Wookies"
} ]
它是無效的json。請點擊此處http://jsonlint.com – 2013-03-11 11:25:53
您的JSON結構中很可能有一個非打印字符,這會扼殺解析器。驗證您的數據源並確保傳入的數據在分析之前是乾淨的。在ID 67之前的 – Perception 2013-03-11 11:27:21
,在JSON中有'.'。如果你刪除這個。它會有效。雖然它沒有出現在這裏。但如果你在這裏嘗試,你會看到一個額外的'.' 67前http://jsoneditoronline.org – 2013-03-11 11:29:14