json idu0075 sissejuhatus veebiteenustesse. json stands for javascript object notation json is...

10
JSON IDU0075 Sissejuhatus veebiteenustesse

Upload: grant-goodman

Post on 18-Dec-2015

222 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: JSON IDU0075 Sissejuhatus veebiteenustesse.  JSON stands for JavaScript Object Notation  JSON is lightweight text-data interchange format  JSON is

JSONIDU0075 Sissejuhatus veebiteenustesse

Page 2: JSON IDU0075 Sissejuhatus veebiteenustesse.  JSON stands for JavaScript Object Notation  JSON is lightweight text-data interchange format  JSON is

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

What is JSON?

Page 3: JSON IDU0075 Sissejuhatus veebiteenustesse.  JSON stands for JavaScript Object Notation  JSON is lightweight text-data interchange format  JSON is

JSON is plain text JSON is "self-describing" (human readable) JSON is hierarchical (values within values) JSON can be parsed by JavaScript JSON data can be transported using AJAX

Much Like XML

Page 4: JSON IDU0075 Sissejuhatus veebiteenustesse.  JSON stands for JavaScript Object Notation  JSON is lightweight text-data interchange format  JSON is

No end tag Shorter Quicker to read and write Can be parsed using built-in JavaScript eval() Uses arrays No reserved words

Much Unlike XML

Page 5: JSON IDU0075 Sissejuhatus veebiteenustesse.  JSON stands for JavaScript Object Notation  JSON is lightweight text-data interchange format  JSON is

Data is in name/value pairs Data is separated by comma Curly brackets holds objects Square brackets holds arrays

{ "firstName":"John" , "lastName":"Doe" }

JSON Syntax Rules

Page 6: JSON IDU0075 Sissejuhatus veebiteenustesse.  JSON stands for JavaScript Object Notation  JSON is lightweight text-data interchange format  JSON is

{"employees": [{ "firstName":"John" , "lastName":"Doe" }, { "firstName":"Anna" , "lastName":"Smith" }, { "firstName":"Peter" , "lastName":"Jones" }]}

JSON Syntax Rules

Page 7: JSON IDU0075 Sissejuhatus veebiteenustesse.  JSON stands for JavaScript Object Notation  JSON is lightweight text-data interchange format  JSON is

{"firstName": „Peeter", "lastName": „Porgand", "address": {

"streetAddress": „Ehitajate tee 5-III 301", "city": „Tallinn", "postalCode": „123456“

}, "phoneNumbers": [ "812 123-1234", "916 123-4567" ] }

JSON example

Page 8: JSON IDU0075 Sissejuhatus veebiteenustesse.  JSON stands for JavaScript Object Notation  JSON is lightweight text-data interchange format  JSON is

<person> <firstName>Peeter</firstName>

<lastName>Porgand</lastName> <address>

<streetAddress>Ehitajate tee</streetAddress> <city>Tallinn</city>

<postalCode>123455</postalCode> </address> <phoneNumbers>

<phoneNumber>812 123-1234</phoneNumber> <phoneNumber>916 123-4567</phoneNumber> </phoneNumbers> </person>

Same in XML

Page 9: JSON IDU0075 Sissejuhatus veebiteenustesse.  JSON stands for JavaScript Object Notation  JSON is lightweight text-data interchange format  JSON is

http://www.w3schools.com/json/tryit.asp?filename=tryjson_eval

JSON to JavaScript

Page 10: JSON IDU0075 Sissejuhatus veebiteenustesse.  JSON stands for JavaScript Object Notation  JSON is lightweight text-data interchange format  JSON is

Aitäh!Julia Labunets 104234IABB51