對不起,這個問題可能會被問幾百次,我尋找類似的問題,但我無法找到一個線索,爲什麼我仍然收到此錯誤。JSON.parse導致意外的令牌錯誤消息
當我嘗試解析下面的特定字符串時,它會顯示「語法錯誤:意外的標記」。這是JS代碼:
var a = "[{"ltd":"40.88393692299686","lng":"29.40516471862793","country":"Türkiye","city":"İstanbul","address":"Tepeören Mh., 2. Caddesi, 41480 Istanbul-Istanbul Province, Turkey","title":"Indoor Life Facory","detail":"İTOSB 2.Cad. No.7 Tuzla/istanbul/Turkey","addressTypeId":1,"adressType":"Üretim Birimi"},{"ltd":"40.97575903170847","lng":"29.051960706710815","country":"Türkiye","city":"İstanbul","address":"Fenerbahçe Mh., Bağdat Avenue 184-190, 34724 Kadıköy-Istanbul Province, Turkey","title":"Indoor Life Head Office","detail":"Bağdat Cad. Heper Apt. \r\nNo:165/5 34730 \r\nSelamiçeşme/Kadıköy/İstanbul/Turkey","addressTypeId":2,"adressType":"İdari Birim"}]";
a = a.replace(/"/g, '"');
var jsonList = JSON.parse(a);
需要更換'/ R/N'使用正則表達式,然後做JSON.parse – 2014-10-19 19:52:51