"{\"id\":20,\"Title\":\"Parti 8\",\"Description\":\"Parti ve daha çok parti iste bu açikalamada, bilmeyenler anlamaz dedigimiz bir parti ve parti iste budur o parti\",\"StartTime\":\"2015-11-04T21:00:00\",\"EndTime\":\"2015-12-04T01:00:00\",\"State\":0}"
我有这个由
序列化的json字符串 JsonConvert.SerializeObject()
但是当我尝试用
反序列化它时Newtonsoft.Json.JsonConvert.DeserializeObject<Party>(JSON)
我得到了这个例外
Newtonsoft.Json.JsonSerializationException:转换值“{”id“时出错:”标题“:”Parti 8“,”描述“:”Parti vedahaçokpartiistebuççalamada,bilmeyenler anlamaz dedigimiz bir parti ve parti iste budur o parti“,”StartTime“:”2015-11-04T21:00:00“,”EndTime“:”2015-12-04T01:00:00“,”State“:0}”输入'PMApp。 Models.Party”。路径'',第1行,第254位。
这是党的实体
public class Party
{
[JsonProperty(PropertyName="id")]
public int id { get; set; }
[JsonProperty(PropertyName = "Title")]
public string Title { get; set; }
[JsonProperty(PropertyName = "Description")]
public string Description { get; set; }
[JsonProperty(PropertyName = "StartTime")]
public DateTime StartTime { get; set; }
[JsonProperty(PropertyName = "EndTime")]
public DateTime EndTime { get; set; }
[JsonProperty(PropertyName = "State")]
public int State { get; set; }
}
修改
var result = response.Content.ReadAsStringAsync().Result;
"\"{\\\"id\\\":20,\\\"Title\\\":\\\"Parti 8\\\",\\\"Description\\\":\\\"Parti ve daha cok parti iste bu acikalamada, bilmeyenler anlamaz dedigimiz bir parti ve parti iste budur o parti\\\",\\\"StartTime\\\":\\\"2015-11-04T21:00:00\\\",\\\"EndTime\\\":\\\"2015-12-04T01:00:00\\\",\\\"State\\\":0,\\\"Place\\\":{\\\"id\\\":14,\\\"Title\\\":\\\"Novo\\\",\\\"Address\\\":\\\"Sofyalı Sok. No:3 Beyoğlu Asmalı Mescit \\\",\\\"PhoneNumber\\\":\\\"0212 2525952\\\",\\\"Genres\\\":null,\\\"Parties\\\":null}}\""
当我调试时,这是结果字符串。当我直接从异常中复制文本时,它工作正常。我尝试更换反斜杠,但它没有用。有什么想法吗?