如何轻松为Json对象创建类

时间:2019-08-05 06:16:09

标签: c# json

我正在尝试使用此对象创建一个类的List

{
  "801": {
    "Name": "SomeWhere",
    "Lanes": {
      "2": {
        "Ip": "172.23.101.21"
      },
      "4": {
        "Ip": "172.23.101.41"
      },
      "6": {
        "Ip": "172.23.101.61"
      },
      "8": {
        "Ip": "172.23.101.81"
      },
      "9": {
        "Ip": "172.23.101.91"
      },
      "11": {
        "Ip": "172.23.101.111"
      }
    }
  },
  "803": {
    "Name": "OverThere",
    "Lanes": {
      "3": {
        "Ip": "172.23.103.31"
      },
      "6": {
        "Ip": "172.23.103.61"
      }
    }
  }
}

我需要它能够像这样使用它:List<ClassOfJson> jsonData = new List<ClassOfJson>();

我在C#中使用Newtonsoft

您能帮我吗?谢谢。

1 个答案:

答案 0 :(得分:2)

您可以尝试在Visual Studio中使用Edit->Paste Special->Paste JSON as classes