2017, Fall Pusan National University Ki-Joune Li

Slides:



Advertisements
Similar presentations
Copyright © Steven W. Johnson
Advertisements

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.
Ku-Yaw Chang Assistant Professor, Department of Computer Science and Information Engineering Da-Yeh University.
Databases.  Multi-table queries  Join ▪ An SQL JOIN clause is used to combine rows from two or more tables, based on a common field between them. 
RESTful applications Norman White. REST Representational state transfer Key concepts – Client Server architecture built on transferring resources between.
Introduction to JavaScript Gordon Tian
JSON Java Script Object Notation Copyright © 2013 Curt Hill.
JSON and A Comparison of Scripts. JSON: JavaScript Object Notation Based on a subset of the JavaScript Programming Language provides a standardized data.
4. Javascript M. Udin Harun Al Rasyid, S.Kom, Ph.D Lab Jaringan Komputer (C-307) Desain.
AJAX. Ajax  $.get  $.post  $.getJSON  $.ajax  json and xml  Looping over data results, success and error callbacks.
CHAPTER 8 AJAX & JSON WHAT IS AJAX? Ajax lets you…
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.
Google maps engine and language presentation Ibrahim Motala.
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)
Framework and Graph Visualization Tools
The Fat-Free Alternative to XML
Storing Data.
Servlets What is a Servlet?
Build in Objects In JavaScript, almost "everything" is an object.
Using JMP® Visualization for A Bike-Sharing Program in NYC
The Fat-Free Alternative to XML
JavaScript is a programming language designed for Web pages.
JSON.
Firebase Realtime Database
Exporting and Importing Data
JSON Crash Course Traversy Media.
Exporting and Importing Data
Database Systems Week 12 by Zohaib Jan.
Scope, Objects, Strings, Numbers
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.
Advanced Topics in Concurrency and Reactive Programming: MEAN Stack
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)
HTML5 AJAX & JSON APIs
CS5220 Advanced Topics in Web Programming JavaScript Basics
JSON Data Demo.
2017, Fall Pusan National University Ki-Joune Li
Intro to NoSQL Databases
JSON for the Data Mortal
JavaScript MCS/BCS.
Department of Computer Science Cal State East Bay, Hayward, CA
Sampath Jayarathna Cal Poly Pomona
CS 240 – Advanced Programming Concepts
JavaScript Basics What is JavaScript?
Lecture 5- Semi-Structured Data (XML, JSON)
Semi-Structured Data (XML, JSON)
The Fat-Free Alternative to XML
Both XML ad JSON are designed to transport data
CS3220 Web and Internet Programming JavaScript Basics
JSON: JavaScript Object Notation
Web Client Side Technologies Raneem Qaddoura
Intro to NoSQL Databases
Presentation transcript:

2017, Fall Pusan National University Ki-Joune Li JSON 2017, Fall Pusan National University Ki-Joune Li

JSON – Basic Concepts JSON (JavaScript Object Notation) A Format (or Syntax) to store and exchange object data Text data Browser Web Server JavaScript Object JSON From JavaScript Object to JSON var myObj = { "name":"John", "age":31, "city":"New York" }; var myJSON = JSON.stringify(myObj); window.location = "demo_json.php?x=" + myJSON; From JSON Object to JavaScript var myJSON = '{ "name":"John", "age":31, "city":"New York" }'; var myObj = JSON.parse(myJSON); document.getElementById("demo").innerHTML = myObj.name;

JSON – Basic Concepts JSON (JavaScript Object Notation) Storing data in local storage as text data JavaScript Program JavaScript Object JSON Local Storage Storing data: myObj = { "name":"John", "age":31, "city":"New York" }; myJSON = JSON.stringify(myObj); localStorage.setItem("testJSON", myJSON); Reading data text = localStorage.getItem("testJSON"); obj = JSON.parse(text); document.getElementById("demo").innerHTML = obj.name;

Syntax JSON object in JavaScript Use JavaScript Syntax Data is in name/value pairs Data is separated by commas Curly braces hold objects Square brackets hold arrays JSON object in JavaScript JSON object is accessible in JavaScript { "name":"John",  "age":30,  "car":null  } var person = { "name":"John", "age":31, "city":"New York" }; var x=person.name; var y=person["name"]; // named index var person["name"]="Guilbert";

JSON – Data Types and Values JSON values must be one of the following types a string (should be always doubl-quoted): {"name":"John" } a number:  {"name":"John" } an object (JSON object): { "employee":{"name":"John", "age":30, "city":"New York" } } an array: {"employees":[ "John", "Anna", "Peter" ] } a boolean: {“married”:true} null: { “middlename”: null} JSON file: .json

JSON – Object Accessing JSON Object within JavaScript JSON Object JSON objects are surrounded by curly braces {}. JSON objects are written in key/value pairs. Keys must be strings, and values must be a valid JSON data type (string, number, object, array, boolean or null). Keys and values are separated by a colon. Each key/value pair is separated by a comma. Accessing JSON Object within JavaScript myObj = { "name":"John", "age":30, "car":null }; x = myObj.name; x = myObj["name"]; myObj = { "name":"John", "age":30, "car":null }; for (x in myObj) {     document.getElementById("demo").innerHTML += myObj[x] + "<br>"; }

JSON – Object Nested JSON Objects Values in a JSON object can be another JSON object. myObj = {     "name":"John",     "age":30,     "cars": {         "car1":"Ford",         "car2":"BMW",         "car3":"Fiat"     }  } x = myObj.cars.car2; //or: x = myObj.cars["car2"]; myObj.cars["car2"] = "Mercedes"; delete myObj.cars.car2;

JSON – Object JSON Array Objects Values in a JSON object can be another JSON object. <!DOCTYPE html> <html> <body> <p>Loopin through an array using a for loop:</p> <p id="demo"></p> <script> var myObj, i, x = ""; myObj = { "name":"John", "age":30, "cars":[ "Ford", "BMW", "Fiat" ] }; for (i = 0; i < myObj.cars.length; i++) { x += myObj.cars[i] + "<br>"; } document.getElementById("demo").innerHTML = x; </script> </body> </html> for (i in myObj.cars) {

JSON – Object myObj = {     "name":"John",     "age":30,     "cars": [         { "name":"Ford", "models":[ "Fiesta", "Focus", "Mustang" ] },         { "name":"BMW", "models":[ "320", "X3", "X5" ] },         { "name":"Fiat", "models":[ "500", "Panda" ] }     ]  }

JSON – Parse and Stringify var obj = { "name":"John", "age":30, "city":"New York"}; var myJSON = JSON.stringify(obj); Convert JavaScript Object to JSON: Stringify Browser Web Server JavaScript Object JSON Convert JSON to JavaScript Objects: parsing var obj = JSON.parse('{ "name":"John", "age":30, "city":"New York"}');

JSON – XML vs. JSON Both JSON and XML can be used to receive data from a web server. {"employees":[     { "firstName":"John", "lastName":"Doe" },     { "firstName":"Anna", "lastName":"Smith" },     { "firstName":"Peter", "lastName":"Jones" } ]} <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>

JSON – XML vs. JSON JSON is like XML JSON is unlike XML 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 XMLHttpReques JSON is unlike XML JSON doesn't use end tag JSON is shorter JSON is quicker to read and write JSON can be included within JavaScript (e.g. object, arrays) XML has to be parsed with an XML parser. JSON can be parsed by a standard JavaScript function JSON.parse