JSON serializers
Unlike BinaryFormatter
, JSON serialization serializes data in a human-readable format. Using XmlSerializer
also produces XML that is human-readable, but JSON serialization produces a smaller data size than XmlSerializer
. JSON is primarily used to exchange data and can be used with many different programming languages (as can XML).
Getting ready
From the Tools
menu, go to NuGet Package Manager
and click on the Manage NuGet Packages for Solution...
menu. In the Browse
tab, search for Newtonsoft.Json
and install the NuGet package. Newtonsoft.Json
is a high-performance JSON framework for .NET. Once it is installed, you will see that the reference Newtonsoft.Json
has been added to your project, References
.
In the using
statements for your class, add the following namespaces using Newtonsoft.Json;
and using Newtonsoft.Json.Linq;
to your code.
How to do it...
- Start off by creating the
FundamentalProgramming
andStudent
classes we used before forXmlSerializer
. This time, remove all...