JSON: JavaScript Object Notation

Slides:



Advertisements
Similar presentations
Copyright © Steven W. Johnson
Advertisements

XML: text format Dr Andy Evans. Text-based data formats As data space has become cheaper, people have moved away from binary data formats. Text easier.
JavaScript Object Notation
JSON Valery Ivanov.
JSON IDU0075 Sissejuhatus veebiteenustesse.  JSON stands for JavaScript Object Notation  JSON is lightweight text-data interchange format  JSON is.
15-Jul-15 JSON. JSON example “JSON” stands for “JavaScript Object Notation” Despite the name, JSON is a (mostly) language-independent way of specifying.
JSON (JavaScript Object Notation).  A lightweight data-interchange format  A subset of the object literal notation of JavaScript (or ECMA-262).  A.
JSON The Fat Free Alternative to XML. Data Interchange The key idea in Ajax. An alternative to page replacement. Applications delivered as pages. How.
RESTful applications Norman White. REST Representational state transfer Key concepts – Client Server architecture built on transferring resources between.
Copyright © Curt Hill Sounds, Resource Packs, JSON What more would you want?
JSON-LD. JSON as an XML Alternative JSON is a light-weight alternative to XML for data- interchange JSON = JavaScript Object Notation – It’s really language.
Serialization. Serialization is the process of converting an object into an intermediate format that can be stored (e.g. in a file or transmitted across.
JSON Java Script Object Notation Copyright © 2013 Curt Hill.
JSON Android Club 2015.
Creating Dynamic Webpages
JSON – Java Script Object Notation. What is JSON JSON is a data interchange format Interactive Web 2.0 applications, no more use page replacement. Data.
AJAX. Ajax  $.get  $.post  $.getJSON  $.ajax  json and xml  Looping over data results, success and error callbacks.
OVERVIEW AND PARSING JSON. What is JSON JavaScript Object Notation Used to format data Commonly used in Web as a vehicle to describe data being sent between.
Dr. Abdullah Almutairi Spring PHP is a server scripting language, and a powerful tool for making dynamic and interactive Web pages. PHP is a widely-used,
JSON. JSON as an XML Alternative JSON is a light-weight alternative to XML for data- interchange JSON = JavaScript Object Notation It’s really language.
JSON (Copied from and from Prof Da Silva) Week 12 Web site:
XML & JSON. Background XML and JSON are to standard, textual data formats for representing arbitrary data – XML stands for “eXtensible Markup Language”
11 jQuery Web Service Client. 22 Objectives You will be able to Use JSON (JavaScript Object Notation) for communcations between browser and server methods.
WELCOME MIDHUN SUDHAKAR twitter.com/midhunopus in.linkedin.com/pub/midhunsudhakar/86/a65/a9.
Introduction to Mongo DB(NO SQL data Base)
PHP using MySQL Database for Web Development (part II)
The Fat-Free Alternative to XML
Storing Data.
COMP9321 Web Application Engineering Semester 1, 2017
Using JMP® Visualization for A Bike-Sharing Program in NYC
The Fat-Free Alternative to XML
JSON.
Exporting and Importing Data
JSON Crash Course Traversy Media.
JSON-LD.
Exporting and Importing Data
Database Systems Week 12 by Zohaib Jan.
Meet JSON In SQL Server 2016 Russ Loski Preparations:
Social Media Apps Programming
Consuming Java Script Object Notation (JSON) feeds
JavaScript Object Notation
JSON Object and JSON Schema
Session V HTML5 APIs - AJAX & JSON
JavaScript an introduction.
Week 11 Web site: XML DOM Week 11 Web site:
Meet JSON In SQL Server 2016 Russ Loski Preparations:
Built in Fairfield County: Front End Developers Meetup
Meet JSON In SQL Server 2016 Russ Loski Preparations:
Intro to NoSQL Databases
HTML Level II (CyberAdvantage)
PHP.
HTML5 AJAX & JSON APIs
2017, Fall Pusan National University Ki-Joune Li
Javascript & jQuery XML.
JSON Data Demo.
Intro to NoSQL Databases
JSON for the Data Mortal
MIS JavaScript and API Workshop (Part 3)
Department of Computer Science Cal State East Bay, Hayward, CA
Sampath Jayarathna Cal Poly Pomona
CS 240 – Advanced Programming Concepts
JSON for Linked Data: a standard for serializing RDF using JSON
Lecture 5- Semi-Structured Data (XML, JSON)
Semi-Structured Data (XML, JSON)
The Fat-Free Alternative to XML
XML/JSON/AJAX Master a Skill / Learn for Life
Web Client Side Technologies Raneem Qaddoura
JSON-LD.
Intro to NoSQL Databases
Extensible Markup Language (XML)
Presentation transcript:

JSON: JavaScript Object Notation Sampath Jayarathna Cal Poly Pomona

JSON as an XML Alternative JSON = JavaScript Object Notation It’s really language independent most programming languages can easily read it and instantiate objects or some other data structure JSON is a light-weight alternative to XML for data- interchange Started gaining tracking ~2006 and now widely used http://json.org/ has more information

JSON Data – A name and a value A name/value pair consists of a field name (in double quotes), followed by a colon, followed by a value Unordered sets of name/value pairs Begins with { (left brace) Ends with } (right brace) Each name is followed by : (colon) Name/value pairs are separated by , (comma) { "employee_id": 1234567, "name": "Jeff Fox", "hire_date": "1/1/2013", "location": "Norwalk, CT", "consultant": false }

JSON Data – A name and a value In JSON, values must be one of the following data types: a string a number an object (JSON object) an array a boolean null { "employee_id": 1234567, "name": "Jeff Fox", "hire_date": "1/1/2013", "location": "Norwalk, CT", "consultant": false }

JSON Data – A name and a value Strings in JSON must be written in double quotes. { "name":"John" } Numbers in JSON must be an integer or a floating point. { "age":30 } Values in JSON can be objects. { "employee":{ "name":"John", "age":30, "city":"New York" } } Values in JSON can be arrays. { "employees":[ "John", "Anna", "Peter" ] }

Another example: XML vs JSON <?xml version="1.0"?> <employees>     <employee>         <firstName>John</firstName> <lastName>Doe</lastName>     </employee>     <employee>         <firstName>Anna</firstName> <lastName>Smith</lastName>     </employee>     <employee>         <firstName>Peter</firstName> <lastName>Jones</lastName>     </employee> </employees> {"employees":[     { "firstName":"John", "lastName":"Doe" },     { "firstName":"Anna", "lastName":"Smith" },     { "firstName":"Peter", "lastName":"Jones" } ]}

Class Activity 8 <?xml version="1.0"?> <bookstore> Convert the following bookstore.xml to bookstore.json <?xml version="1.0"?> <bookstore> <book category="sci-fi"> <title lang="en"> 2001</title> <author>Arthur C. Clarke</author> <price>$30.0</price> <year>1968</year> </book> <book> <title lang="rs">Story about a True Man</title> <author>Boris Polevoy</author> <price>$20.00</price> <year>1952</year> </bookstore>

XML vs JSON JSON is Like XML Because JSON is Unlike 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 JSON is Unlike XML Because JSON doesn't use end tag JSON is shorter JSON is quicker to read and write JSON can use arrays JSON has a better fit for OO systems than XML The biggest difference is: XML has to be parsed with an XML parser. JSON can be parsed by a standard JavaScript function.

Why JSON? Steps involved in exchanging data from web server to browser involves: Using XML Fetch an XML document from web server. Use the XML DOM to loop through the document. Extract values and store in variables. It also involves type conversions. Using JSON Fetch a JSON string. Parse the JSON using JavaScript functions.