What's Json.NET

What is JSON ?

JSON(Javascript Object Notation) is a lightweight data format and is one of the widely used data format to transfer data between a server and a client. In JSON the data is transferred in text format and normaly in the form of Key Value Pairs. 

Sample JSON

{
  "FirstName": "Amal",
  "LastName": "Dev
}

So we developers most often stumble across scenarios where we need to map this attributes in JSON to domain entity.  Mapping each attribute in the JSON to the properties of a class is tedious as well as a repetitive job. That's where frameworks such as Json.NET comes in handy, it helps you map the items using one single statment.

Json.NET

Json.NET  is the most popular of them all and is widely used acros the world. Such is its performance and popularity that it became the defacto way of passing data in ASP.NET Web API. It started as a hobby project having very limited features and by 2006 it evolved into a great product with lot of features culminating with the release of the first version.

Another great advantage of using Json.NET is that it's a open sourced project and is free for commercial use too.

Features

Has a great serializer for converting .NET objects to JSON

High Performance

Creates indented JSON

Conversion from XML to JSON and vice versa

Supports frameworks from .Net 2.0 to 4.5, Silverlight, UWP

It's a free library and you can add to your project by either manually executing the command from the Package Manager Console window or by using the Package Manager in Visual Studio

Using Package Manager Console

Install-Package Newtonsoft.Json

Once the installation is completed, it will open a new tab with web page for Json.NET and under the References you can see that Json.NET is showing up now

Using Package Manager

Click on Tools -< NuGet Package Manager -> Manage Packages for the Solution

Search for newtonsoft in the Browse tab. Select Newtonsoft.Json from the search result, If you solution has got multiple projects, option is there to select the projects which needs Json.NET. Once you click the install button, a dialog will be shown with the summary.

To uninstall you can use the following command in console

Uninstall-Package Newtonsoft.Json


No Comments

Add a Comment