Once you've successfully installed xsd2Code all you have to do is put you Json schema into the project in Visual Studio from there all you have to do is right click the file and you should see an xsd2Code option in the menu
Once the tool starts running you will see a preview of what your generated class will look like, if anything bothers you in it, do not fret you have quite a large number of options on the left of the screen
For example, personnally I prefer my gets and sets in the simple automatic way this can be changed like many other things on the left side of your screen. In my case the property I need to change is nested in the Output property settings' Properties, what we're looking for is the Automatic properties setting that should be on False.
Once you put this setting on True you should see the program regenerate your class with the appropriate changes, in our example it should now look like this.
You can check out our other articles to see what can be done with the other settings, but for now let's move on.
Once you're satisfied with your options, you can continue by clicking generate at the bottom right corner
Once your class is generated, you're ready to go, have fun !
But if you're willing to stay a bit longer I can show you how to make use of some of the functions this tool can generate for you to write and read json files.
By default the generation of these functions is turned off, to turn them on you need to look for the Serialization option in the Output advanced code settings.
Make sure to have the proper filetype selected in the DefaultSerializer in our case it's Json, make sure it is all Enabled in the Enabled setting.
(If you see errors relating to NewtonSoft don't worry we'll get to it)
Once the settings are set and you press generate your class or classes should have a couple of new functions :
You won't need to interact with the serialization part of the code unless you know what you're doing
Assuming you're working with single objects and not a list of them (An array would be better) when you use the Customers' (in our case) SaveToFile property with a valid path argument it will write that instance of the object into the file after serializing into the right format. The same thing but in the opposite direction happens when you LoadFromFile
But you might've seen errors in the class, that comes from the fact that you probably haven't installed Newtonsoft, it's because these functions use the Newtonsoft Json.Net : https://www.newtonsoft.com/json
You need to add the NuGet of Newtonsoft.Json, once you did that everything should work fine.
Thank you for using our product, if you want to learn check out our other articles on the things you can do with XSD2Code