मेरे पास 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वर्ग), यह ठीक से deserialize नहीं है और मुझे देता है null। मैं इससे कैसे उबरूं?