0

I need some help to convert this kind of JSON object in to c# classes so than I can Deserialize it

Here how it looks:

{  
   "Result":{  
      "test_one":"test",
      "test_two":"test",
      "main":[  
         {  
            "@attributes":{  
               "ID":"1",
               "Name":"test1"
            }
         },
        {  
            "@attributes":{  
               "ID":"2",
               "Name":"test2"
            }
         }
      ]
   }
}
Stefanija
  • 1,338
  • 2
  • 12
  • 24
  • Take a look at the newtonsoft nuget package, it will handle everything for you. Here is the link to the documentation. http://www.newtonsoft.com/json/help/html/DeserializeObject.htm – TheMiddleMan Mar 16 '17 at 13:30
  • This has been asked before. Have a look at http://stackoverflow.com/questions/2246694/how-to-convert-json-object-to-custom-c-sharp-object – Ben Cameron Mar 16 '17 at 13:30
  • Those two links explain on simple json object this one is more complex that is why I am confised – Stefanija Mar 16 '17 at 13:32

2 Answers2

0

You could use an online converter :) This one will work for your json: json2csharp

Mighty Badaboom
  • 5,854
  • 5
  • 29
  • 50
0
  1. Add new class
  2. Copy your json
  3. Visual Studio Menu > Edit > Paste Special > Paste JSON as Classes
Murat Gündeş
  • 814
  • 2
  • 18
  • 29