相关疑难解决方法(0)

.NET NewtonSoft JSON将映射反序列化为不同的属性名称

我有以下从外部方收到的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"
         }
      }
   ]
}
Run Code Online (Sandbox Code Playgroud)

我的映射类:

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
{ …
Run Code Online (Sandbox Code Playgroud)

serialization json json.net deserialization c#-4.0

271
推荐指数
5
解决办法
20万
查看次数

标签 统计

c#-4.0 ×1

deserialization ×1

json ×1

json.net ×1

serialization ×1