Building User Interfaces Javascript
[Pages:52]Building User Interfaces
Javascript
Intermediate Concepts
Professor Yuhang Zhao
Adapted from Prof. Mutlu's slides
Building User Interfaces | Professor Zhao | Lecture 03 -- Javascript 2: Intermediate Concepts
What we will learn today?
-- Working with JSON data -- , CSS/No-CSS -- Working with APIs -- Working with component libraries
Building User Interfaces | Professor Zhao | Lecture 03 -- Javascript 2: Intermediate Concepts
Live Q&A Reminder
Building User Interfaces | Professor Zhao | Lecture 03 -- Javascript 2: Intermediate Concepts
Working with JSON data
Building User Interfaces | Professor Zhao | Lecture 03 -- Javascript 2: Intermediate Concepts
What is JSON?
Definition: JavaScript Object Notation ( JSON) is a structured way to represent text-based data based on JS object syntax. JSON can include any JS data type. Do you remember how many types there are?
{ string : value, .......}
Building User Interfaces | Professor Zhao | Lecture 03 -- Javascript 2: Intermediate Concepts
Refresher: JS Objects
Definition: Objects are unordered collection of related data of primitive or reference types.
Object elements are defined using key: value statements.
var instructor = { firstName: "Yuhang", lastName: "Zhao", gender: "female"
} instructor; > {firstName: "Yuhang", lastName: "Zhao", gender: "female"}
Building User Interfaces | Professor Zhao | Lecture 03 -- Javascript 2: Intermediate Concepts
JSON Objects:
{ "firstName": "Yuhang", "lastName": "Zhao", "role": "instructor", "email": "yuhang.zhao@cs.wisc.edu" }
JSON Arrays:
{ "TAs" : [ { "Name": "Brandon" , "Year": "First" }, { "Name": "Sujitha" , "Year": "First" }, { "Name": "Salman" , "Year": "First" }]}
Building User Interfaces | Professor Zhao | Lecture 03 -- Javascript 2: Intermediate Concepts
How to use JSON data1
var text = '{ "TAs": [' + '{ "Name":"Brandon Cegelski" , "Year":"First" },' + '{ "Name":"Sujitha Perumal" , "Year":"First" },' + '{ "Name":"Salman Munaf" , "Year":"First" }]}';
obj = JSON.parse(text);
document.getElementById("TANames").innerHTML = "Our TAs are " + obj.TAs[0].Name + " and " + obj.TAs[1].Name + ".";
1 See a working example in CodePen
Building User Interfaces | Professor Zhao | Lecture 03 -- Javascript 2: Intermediate Concepts
................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related download
- client server interactions in react polito
- fetch api polito
- dkan documentation
- dynamic view rendering using reactjs and jquery
- android with react pdf
- more inside the classes
- extracting and managing structured web data
- react native microsoft azure
- building user interfaces javascript
- building maintainable web applications using react