From the course: Visual Studio Developer Tips

Unlock this course with a free trial

Join today to access over 22,600 courses taught by industry experts.

Paste JSON/XML as class

Paste JSON/XML as class

- [Instructor] JSON and XML files are a common way to serialize object content into a file. Once the object state is inside the JSON or XML file, then you can persist the file to a cloud. Later, you can open the JSON file, de-serialize the state, rehydrate the object. In this example I have here, I've got a JSON file. And this represents the state of the object. I would have had a class, probably, with a property name StopNumber. And this was the value that was stored in the file. And there's a property called Name, and this is the string that was stored inside the file. The rest of these are different properties in the class. There's usually a one-to-one relationship between the data that is in this file and the properties or fields that are in your object. What I want to look at in this tip is when you have a JSON file like this but don't you have the correct class file yet. Now that could be the case when you're working with an API and you're getting the JSON data. Or it could be…

Contents