我有下一个 JSON:
"jsonrpc":"2.0",
"id":1,
"result":
{
"1375833600000":
{
"notifications":[],
"events":[],
"lectures":[],
"birthdays":[
{
"id":"BB390BEE-CCBE-4D42-849C-E5040D6FD12C",
"date":1375909200000,
"name":"Test test",
"previewPhoto":"https://link.com/public/photos/h66/BB390BEE-CCBE-4D42-849C-E5040D6FD12C.jpg"
}]
},
"1375833600001":
{
"notifications":[],
"events":[],
"lectures":[],
"birthdays":[
{
"id":"BB390BEE-CCBE-4D42-849C-E5040D6FD12C",
"date":1375909200000,
"name":"Test test",
"previewPhoto":"https://link.com/public/photos/h66/BB390BEE-CCBE-4D42-849C-E5040D6FD12C.jpg"
}]
},
我不明白在结果中为字符串属性写什么:
class Schedule
{
[JsonProperty("jsonrpc")]
public string Jsonrpc { get; set; }
[JsonProperty("id")]
public string Id { get; set; }
[JsonProperty("result")]
public Result Result { get; set; }
}
public class Result
{
How to handle this: "1375833600000"
"1375833600001"
}
我知道它是像 Result 一样的数组,但它有不同的名称
我试过这个:
class Schedule
{
[JsonProperty("jsonrpc")]
public string Jsonrpc { get; set; }
[JsonProperty("id")]
public string Id { get; set; }
private List<Results> result = new List<Results>();
[JsonProperty("result")]
public List<Results> Result { get { return result; } }
}
public class Results
{
private List<Event> events = new List<Event>();
[JsonProperty("events")]
public List<Event> Events { get { return events; } }
private List<Birthday> birthdays = new List<Birthday>();
[JsonProperty("birthdays")]
public List<Birthday> Birthdays { get { return birthdays; } }
}
public class Event
{
[JsonProperty("id")]
public int Id { get; set; }
[JsonProperty("datetime")]
public long Datetime { get; set; }
[JsonProperty("title")]
public string Title { get; set; }
[JsonProperty("link")]
public string Link { get; set; }
[JsonProperty("description")]
public string Description { get; set; }
[JsonProperty("allDayEvent")]
public bool AllDayEvent { get; set; }
}
public class Birthday
{
[JsonProperty("id")]
public int Id { get; set; }
[JsonProperty("date")]
public long Date { get; set; }
[JsonProperty("name")]
public string Name { get; set; }
[JsonProperty("previewPhoto")]
public string PreviewPhoto { get; set; }
}
但它失败了