JSON
What is JSON?
2
JSON stands for JavaScript Object Notation
JSON is an open standard file format for storing and transporting data.
JSON is a lightweight data-interchange format
JSON is "self-describing" and easy to understand
JSON is language independent
The file type for JSON files is ".json"
Valid Data Types
3
In JSON, values must be one of the following data types:
a string
a number
an object (JSON object)
an array
a boolean
null
JSON Syntax Rules
4
JSON syntax is derived from JavaScript object notation
syntax rules:
Data in the form of name/value pairs
Begins with {
Ends with }
Name / value pairs are separated by commas
Curly braces hold objects { }
Square brackets hold arrays [ ]
Example
5
<script>
var jsonobject ={
“firstname” : “Naveen”,
“lastname” : “Kharwal”,
“age” : 22
“ramdom_nums” : [21,22,23,24,25]
}
documents.write(jsonobject)
</script>
JSON vs XML
6
Both JSON and XML can be used to receive data from a web server.
JSON is Like XML Because
Both JSON and XML are "self describing" (human readable)
Both JSON and XML are hierarchical (values within values)
Both JSON and XML can be parsed and used by lots of programming languages
Both JSON and XML can be fetched with an XMLHttpRequest
JSON is Unlike XML Because
7
JSON is lighter and faster than XML
JSON doesn't use end tag
JSON is shorter
JSON is quicker to read and write
JSON can use arrays

An introduction to json

  • 1.
  • 2.
    What is JSON? 2 JSONstands for JavaScript Object Notation JSON is an open standard file format for storing and transporting data. JSON is a lightweight data-interchange format JSON is "self-describing" and easy to understand JSON is language independent The file type for JSON files is ".json"
  • 3.
    Valid Data Types 3 InJSON, values must be one of the following data types: a string a number an object (JSON object) an array a boolean null
  • 4.
    JSON Syntax Rules 4 JSONsyntax is derived from JavaScript object notation syntax rules: Data in the form of name/value pairs Begins with { Ends with } Name / value pairs are separated by commas Curly braces hold objects { } Square brackets hold arrays [ ]
  • 5.
    Example 5 <script> var jsonobject ={ “firstname”: “Naveen”, “lastname” : “Kharwal”, “age” : 22 “ramdom_nums” : [21,22,23,24,25] } documents.write(jsonobject) </script>
  • 6.
    JSON vs XML 6 BothJSON and XML can be used to receive data from a web server. JSON is Like XML Because Both JSON and XML are "self describing" (human readable) Both JSON and XML are hierarchical (values within values) Both JSON and XML can be parsed and used by lots of programming languages Both JSON and XML can be fetched with an XMLHttpRequest
  • 7.
    JSON is UnlikeXML Because 7 JSON is lighter and faster than XML JSON doesn't use end tag JSON is shorter JSON is quicker to read and write JSON can use arrays