我正在使用Parse.com。
Json回应
{
"AuditoriumId": "P2TTDSNTHM",
"MovieId": "PAcklcCGGa",
"StartDate": {
"__type": "Date",
"iso": "2015-12-09T01:08:00.000Z"
},
"createdAt": "2015-12-07T23:02:34.800Z",
"objectId": "CSwc9M90JQ",
"updatedAt": "2015-12-08T01:08:55.903Z"
}
反序列化:
model = JsonConvert.DeserializeObject<ShowcaseModel>(getParseIdData(showcase + "/" + model.Order.ShowcaseId));
型号:
public class ShowcaseModel
{
public string objectId { get; set; }
public string AuditoriumId { get; set; }
public string MovieId { get; set; }
public DateTimeOffset StartDate { get; set; }
public DateTime? createdAt { get; set; }
public DateTime? updatedAt { get; set; }
}
无论出于何种原因,parse.com都会使用__type发送自定义用户日期属性,但不会为自己的createdAt和updatedAt执行此操作。它显然会引发有关日期格式的错误 - 在json字符串中有__type,我不知道如何解决这个问题。什么是最简单的方法?
答案 0 :(得分:1)
可能最简单的方法是
public class ShowcaseModel
{
public string AuditoriumId { get; set; }
public string MovieId { get; set; }
public Startdate StartDate { get; set; }
public DateTime createdAt { get; set; }
public string objectId { get; set; }
public DateTime updatedAt { get; set; }
}
public class Startdate
{
public string __type { get; set; }
public DateTime iso { get; set; }
}
然后DeserializeObject