Hello Devz,

JSON files are really common, we can see them everywhere. They provide a good structure to organize data, are simpler and lighter than XML files, and still human readable. In this simple example, we will show you how to use the Json.NET library (Newtonsoft) from NuGet. It is pretty simple to serialize and deserialize objects in C#. This tutorial will generate a list of employees, then serialize it to a JSON file to save it as a text file, and then deserialize it to display its content on screen in a simple console application.

Here is our Employee class:

Here is the content of our “employeeList.json” file:

Please observe the options you can provide while serializing you object to JSON. In this case, we used “Formatting.Indented”, which allows us to display the content of the JSON file in a more human readable format with indentations.

Happy coding! 🙂