9
我正在嘗試使用JSON.Net加載本地存儲在ASP.Net MVC 4網站上的JSON文件,但無法指向該文件。這裏是我想要做的事:如何從本地存儲的文件中讀取JSON?
List<Treatment> treatments = JsonConvert.DeserializeObject<List<Treatment>>(Server.MapPath("~/Content/treatments.json"));
和我打這個錯誤:
An exception of type 'Newtonsoft.Json.JsonReaderException' occurred in Newtonsoft.Json.dll but was not handled in user code
Additional information: Unexpected character encountered while parsing value: c. Path '', line 0, position 0.
,我應該怎麼做不同?
請發佈JSON文件。 – Icarus
看起來您的JSON可能無法正確格式化,或者它可能在錯誤的地方有單引號 – Jaypal