Json

3,028 views
2,887 views

Published on

0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
3,028
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
2
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

Json

  1. 1. JSON Basics <br />Shyamala Prayaga<br />
  2. 2. Agenda<br />What is JSON?<br />Why JSON?<br />Pros and Cons<br />JSON Syntax<br />JSON Parser<br />Accessing Data in JSON<br />
  3. 3. What is JSON?<br />Stands for JavaScript Object Notation<br />Is lightweight format for exchanging data between the client and server.<br />Easy for humans to read and write.<br />Easy for machines to parse and generate <br />Often used in Ajax applications due to<br />Its simplicity<br />its format which is based on JavaScript object literals <br />
  4. 4. Why JSON?<br />JSON is recognized natively by JavaScript<br />Simple format<br />The easiness of reading <br />The easiness of using <br />Lighter than XML<br />
  5. 5. Benefits over XML<br />
  6. 6. Pros and Cons<br />
  7. 7. JSON Syntax<br />For objects start the object with “{“ and end it with “}” <br />For members (properties), use pairs of string : value and separate them by commas <br />For arrays put the arrays between [] <br />For elements put the values directly separated by commas <br />
  8. 8. Example <br />var myFirstJSON ={ &quot;firstName&quot; : &quot;John&quot;,      &quot;lastName&quot; : &quot;Doe&quot;,      &quot;age&quot;       : 23 };<br />
  9. 9. JSON Parser<br />You can convert JSON object into JSON text<br />Object to Text Conversion <br /> var myJSONText = myObject.toJSONString();<br />
  10. 10. Accessing Data in JSON<br />The most common way to access JSON data is through dot notation. <br /> var myObject = { &apos;color&apos; : &apos;blue&apos; };document.writeln(myObject.color); <br />
  11. 11. Questions?<br />

×