Introduction
Recently, JSON (JavaScript Object Notation) has become a very popular data interchange format with more and more developers opting for it over XML. Even many web services nowadays provide JSON as the default output format.
JSON is a text format that is programming-language independent and is a native data form of JavaScript. It is lighter and faster than XML because it needs less markup compared to XML.
Because JSON is the native data form of JavaScript, it can be used on the client side in an AJAX application more easily than XML.
A JSON object starts with {
and ends with }
. According to the JSON specification, the following types are allowed in JSON:
Object: An object is a collection of key-value pairs enclosed between
{
and}
and separated by a comma. The key and the value themselves are separated using a colon (:). Think of objects as associative arrays or hash tables. Keys are simple strings and values can be an array, string, number, boolean, or null.Array: Like other languages...