Wednesday, July 15, 2015

When do you use JSON.Net?

JSON is JavaScript Object Notation. You can read all about JSON by reviewing the following:

What is JSON?:
http://hodentekhelp.blogspot.com/2009/02/what-is-json.html

Working with JSON:
http://hodentekhelp.blogspot.com/2014/11/how-do-you-work-with-javascript-object.html

SQL response in JSON:
http://hodentekhelp.blogspot.com/2015/05/how-do-you-obtain-json-formatted.html

Let us take this fruit (object) which has,
Name="Apple"
fruit should be used before (Expiry)=12/28/2008
Sizes=small, big, extra large

This object can be represented it in JSON as:
{
"Name": "Apple",
"Expiry": "2008-12-28T00:00:00",
"Sizes": [
    "Small"
  ]
 }

JSON.NET is a high-performance JSON Framework for .NET.

You can read all about JSON.NET here.

The benefits of using JSON.NET are the following (quoted from the above site):

  • Flexible JSON serializer for converting between .NET objects and JSON
  • LINQ to JSON for manually reading and writing JSON
  • High performance: faster than .NET's built-in JSON serializers
  • Write indented, easy-to-read JSON
  • Convert JSON to and from XML
  • Supports .NET 2, .NET 3.5, .NET 4, .NET 4.5, Silverlight, Windows Phone and Windows 8 Store
 In order to use it in your .NET project you need to add a reference to NewtonSoft.JSON

No comments: