JSON, according to the
official website for JSON, is a lightweight data interchange format that is a
text-based, human readable format that is used to represent objects, arrays,
and other data types that is mainly used to exchange such data types over the
network.
JSON is mainly used in web applications AJAX enabled. Such
applications force their server-side code, which can be PHP, JSP, ASP.NET, etc
… to format the data that they must send back to the requesting client
application in a JSON format. Many benefits can be gained out of this process,
especially performance gain on the client side since there will be no overhead
in generating XML DOM tress out of the XML Data and would be better than simple
text in a string-format because JSON would represent the data received in an
object-fashion! And all that you have to do on the client is just parse that object-string-formatted
into a JSON object and access that object as if you are dealing with a C# or
JAVA object!
Since I am talking about objects and arrays, it is worth
mentioning that JSON is a subset of the object literal notation of JavaScript
and is commonly used with that language. Therefore, since JSON depends on
objects and such Object Oriented types, it can be easily used with an Object
Oriented Language since they all share the same concept of representing data as
objects. Let me show you an example of a JSON object before going on to get a
small idea on what I have been talking from the beginning of this article.
Listing 1: JSON simple object
{
"FirstName": "Bilal",
"LastName": "Haidar",
"Age": 26,
"Experience":
["2004", "2005", "2006"]
}