System.Exception:读取CANANDA的城市列表时出错 - > System.ArgumentException:无法识别的转义序列。 (1056):
{code: "CA",cities: [{name: "Abbotsford",lat: 49029998,lon: -122370002},{name: "Calgary",lat: 51119998,lon: -114019996},{name: "Edmonton",lat: 53299999,lon: -113580001},{name: "Halifax",lat: 44880001,lon: -63500000},{name: "Hamilton",lat: 43279998,lon: -79900001},{name: "Kanata",lat: 45319999,lon: -75669998},{name: "Kelowna",lat: 49970001,lon: -119379997},{name: "Kingston",lat: 44220001,lon: -76599998},{name: "London",lat: 43029998,lon: -81150001},{name: "Mississauga",lat: 43630001,lon: -79400001},{name: "Moncton",lat: 46119998,lon: -64680000},{name: "Montreal",lat: 45470001,lon: -73750000},{name: "Oshawa",lat: 43630001,lon: -79400001},{name: "Ottawa",lat:45319999,lon: -75669998},{name: "Peterborough",lat: 44229999,lon: -78370002},{name: "Prince George",lat: 53880001,lon: -122680000},{name: "Quebec",lat: 46799999,lon: -71379997},{name: "Regina",lat: 50430000,lon: -104669998},{name: "Saint John",lat: 45319999,lon: -65879997},{name: "Saskatoon",lat: 52169998,lon: -106680000},{name: "Sherbrooke",lat: 45430000,lon: -71680000},{name: "St John\x27s",lat: 47619998,lon: -52729999},{name: "Sydney",lat: 46169998,lon: -60049999},{name: "Thunder Bay",lat: 48369998,lon: -89319999},{name: "Toronto",lat: 43630001,lon: -79400001, selected: true},{name: "Trois-Rivieres",lat: 46349998,lon: -72519996},{name: "Vancouver",lat: 49180000,lon: -123169998},{name: "Victoria",lat: 48650001,lon: -123430000},{name: "Windsor",lat: 42270000,lon: -82970001},{name: "Winnipeg",lat: 49900001,lon: -97230003}]}
我认为导致例外的是“St John \ x27s”这个名字。这是否意味着System.Web.Extensions JavaScriptSerializer不支持Unicode? p>
或者这实际上是无效的JSON?
如何解决此问题?
答案 0 :(得分:2)
\ x27是无效的JSON。将其替换为\ u0027。