JSONを解析する次のコードがあり、正常に動作します。
EVENT と SQUAD は JSON 配列です。
配列をソートできるようにするには、どのコードが必要ですか?たとえば、EVENT を TIME でソートしたり、SQUAD を RANK でソートしたりできますか?
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; }
}