Mam następujący ciąg JSON, który jest odbierany od strony zewnętrznej.
{
"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"
}
}
]
}
Moje klasy mapowania:
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; }
}
Pytanie brzmi: nie podoba mi się Attributes nazwa klasy i attributes nazwy pól w Teamklasie. Zamiast tego chcę, aby została nazwana, TeamScorea także usunąć _z nazw pól i nadać imiona własne.
JsonConvert.DeserializeObject<RootObject>(jsonText);
Mogę zmienić nazwę Attributesna TeamScore, ale jeśli zmienię nazwę pola ( attributesw Teamklasie), nie spowoduje to deserializacji poprawnie i da mi null. Jak mogę to przezwyciężyć?