Visually Located


Creating C# classes from JSON (or XML) in Visual Studio 2015

I am continually creating classes from JSON. In the past I have used to accomplish this task. It is a very simply website with one large textbox. Paste your text or a link to text and click the generate button and suddenly you have C# classes! Visual Studio 2015 removes the need for this website. The Visual Studio team has added a new way to paste JSON or XML text and have classes created. This new feature even works better than did. To use the new feature follow the below steps Open a file. If you want to paste JSON the file must be a class file (have the .cs extension). Copy some JSON Select Edit –> Paste Special –> Paste JSON As Classes It will generate as many classes as are needed. I’ll give a few examples to see the benefits of this new feature and how it could be improved. Simple base types { "firstName" : "John", "lastName" : "Doe", "age" : 13, "dateOfBirth" : "2002-10-05T14:13:25-06:00"} And the generated class public c... [More]