У меня есть следующая строка JSON, полученная от внешней стороны.
{
"team":[
{
"v1":"",
"attributes":{
"eighty_min_score":"",
"home_or_away":"home",
"score":"22",
"team_id":"500"
}
},
{
"v1":"",
"attributes":{
"eighty_min_score":"",
"home_or_away":"away",
"score":"30",
"team_id":"600"
}
}
]
}
Мои классы картирования:
public class Attributes
{
public string eighty_min_score { get; set; }
public string home_or_away { get; set; }
public string score { get; set; }
public string team_id { get; set; }
}
public class Team
{
public string v1 { get; set; }
public Attributes attributes { get; set; }
}
public class RootObject
{
public List<Team> team { get; set; }
}
Вопрос в том, что мне не нравятся Attributes имя класса и attributes имена полей в Teamклассе. Вместо этого я хочу, чтобы он был назван, TeamScoreа также удалял _из имен полей и давал имена собственные.
JsonConvert.DeserializeObject<RootObject>(jsonText);
Я могу переименовать Attributesв TeamScore, но если я изменю имя поля ( attributesв Teamклассе), оно не будет десериализовано должным образом и даст мне null. Как я могу преодолеть это?