Friday, January 29, 2016

JSON

JSON


JSON: JavaScript Object Notation.
JSON is syntax for storing and exchanging text information. Much like XML.
JSON is smaller than XML, and faster and easier to parse.

JSON Example

{
“employees”: [
{ “firstName”:”John” , “lastName”:”Doe” },
{ “firstName”:”Anna” , “lastName”:”Smith” },
{ “firstName”:”Peter” , “lastName”:”Jones” }
]
}
The employees object is an array of 3 employee records (objects).

What is JSON?

  • JSON stands for JavaScript Object Notation
  • JSON is lightweight text-data interchange format
  • JSON is language independent
  • JSON is “self-describing” and easy to understand
JSON uses JavaScript syntax for describing data objects, but JSON is still language and platform independent. JSON parsers and JSON libraries exists for many different programming languages.

Why JSON?

For AJAX applications, JSON is faster and easier than XML:
Using XML:
  • Fetch an XML document
  • Use the XML DOM to loop through the document
  • Extract values and store in variables
Using JSON:
  • Fetch a JSON string
  • eval() the JSON string
Click here for more J2EE Interviw Questions

No comments:

Post a Comment