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,388
  • 2
  • 12
  • 25
  • 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 – Agrejus 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
  • 6,067
  • 5
  • 34
  • 51
0
  1. Add new class
  2. Copy your json
  3. Visual Studio Menu > Edit > Paste Special > Paste JSON as Classes
Murat Gündeş
  • 852
  • 2
  • 17
  • 31