我有以下代码,它可以很好地解析 JSON。
EVENT 和 SQUAD 是 JSON 数组。
我需要什么代码才能对数组进行排序,例如在 TIME 上对 EVENT 进行排序,或者在 RANK 上对 SQUAD 进行排序?
void client_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
{
var serializer = new DataContractJsonSerializer(typeof(gameDetails));
gameDetails jsResult = (gameDetails)serializer.ReadObject(e.Result);
...
}
[DataContract]
public class gameDetails
{
[DataMember]
public string HomeTeamScore { get; set; }
[DataMember]
public string AwayTeamScore { get; set; }
[DataMember]
public string FixtureDate { get; set; }
[DataMember]
public string HomeTeamName { get; set; }
[DataMember]
public string AwayTeamName { get; set; }
[DataMember(Name = "EVENT")]
public EVENT[] EVENTS;
[DataMember(Name = "SQUADS")]
public SQUAD[] SQUADS;
}
[DataContract]
public class EVENT
{
[DataMember]
public string TEAMFLAG { get; set; }
[DataMember]
public string TIME { get; set; }
[DataMember]
public string PLAYER { get; set; }
[DataMember]
public string TYPE { get; set; }
}
[DataContract]
public class SQUAD
{
[DataMember]
public string PLSURN { get; set; }
[DataMember]
public string PLID { get; set; }
[DataMember]
public string PLAYER { get; set; }
[DataMember]
public string TEAM { get; set; }
[DataMember]
public string PLFORN { get; set; }
[DataMember]
public string SQUADNO { get; set; }
[DataMember]
public string RANK { get; set; }
}