Ibanez1408
Ibanez1408

Reputation: 5058

How to easily create a class for a Json object

I am trying to create a List of a class with this object:

{
  "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"
      }
    }
  }
}

I need it to be able to use it like this: List<ClassOfJson> jsonData = new List<ClassOfJson>();

I am using Newtonsoft in C#. What can I do to resolve this?

Upvotes: 0

Views: 471

Answers (1)

Pavel Anikhouski
Pavel Anikhouski

Reputation: 23228

You can try to use Edit->Paste Special->Paste JSON as classes command in Visual Studio. You can find more helpful tips and tricks in Visual Studio tips and tricks article

Upvotes: 5

Related Questions