SlideShare a Scribd company logo
Web creation languages : Jason Learn Jason
JSON - JavaScript Object Notation is a lightweight data-interchange format that is easy for
humans to read and write and easy for machines to parse and generate.
Syntax:
JSON syntax is derived from JavaScript object notation syntax:
Data Types: JSON supports primitive data types like strings, numbers, booleans, and null,
as well as complex data types like arrays and objects.
Format: Data is represented in key-value pairs. Keys must be strings enclosed in double
quotes, and values can be any valid JSON data type.
https://youtu.be/iiADhChRriM?si=y_whC20WOnxNDjco
Introduction to JSON
Web creation languages : Jason Learn Jason
Example:
{
"name": "John Doe",
"age": 30,
"isStudent": false,
"courses": ["Math", "Science"],
"address": {
"city": "New York",
"zipCode": "10001"
}
}
Data Format
Text-Based: JSON data is stored as plain text, making it easy to transmit
and store.
Hierarchy: Supports nested structures using arrays and objects,
allowing complex data relationships to be represented.
Platform Independence: Widely supported across programming
languages and platforms, making it ideal for interoperability.
Use Cases:
JSON is commonly used for:
APIs: Many web APIs use JSON for data interchange between servers and
clients.
Configuration Files: Often used for configuration settings due to its
simplicity and readability.
Data Storage: Storing and transmitting structured data in web applications
and databases.
Serialization: Converting objects into JSON format for transmission or
storage, and deserialization vice versa.
JSON's simplicity, readability, and flexibility make it a popular choice for
exchanging data between systems and applications on the web.
Creating JSON objects in JavaScript involves defining and structuring
data using JavaScript syntax, which closely resembles the JSON format
itself. Here’s how you can create and manage JSON objects, including
nesting and handling complex data structures:
JSON Objects
Basic JSON Object Creation:
You can create a JSON object directly in JavaScript by
defining it as a JavaScript object literal enclosed in curly
braces { }
// Define a JSON object
let person = {
"name": "John Doe",
"age": 30,
"isStudent": false,
"courses": ["Math", "Science"],
"address": {
"city": "New York",
"zipCode": "10001"
}
};
console.log(person);
Managing Nesting:
JSON supports nested objects and arrays, allowing you to
represent hierarchical data structures
// Nested JSON object
let nestedObject = {
"name": "John Doe",
"contacts": [
{
"type": "email",
"value": "john.doe@example.com"
},
{
"type": "phone",
"value": "123-456-7890"
}
],
"address": {
"city": "New York",
"zipCode": "10001"
}
};
Dynamically Creating JSON:
You can dynamically add properties and values to a JSON object using
JavaScript’s object notation
// Dynamic JSON creation
let dynamicObject = {};
dynamicObject.name = "Jane Smith";
dynamicObject.age = 25;
dynamicObject.skills = ["JavaScript",
"HTML", "CSS"];
dynamicObject.address = {
"city": "San Francisco",
"zipCode": "94105"
};
console.log(dynamicObject);
Complex Data Structures:
JSON in JavaScript can handle complex data structures such as arrays of
objects or nested objects within arrays
// Complex JSON structure
let complexData = {
"employees": [
{
"name": "Alice",
"department": "Engineering",
"skills": ["JavaScript", "Python"]
},
{
"name": "Bob",
"department": "Marketing",
"skills": ["SEO", "Social Media"]
}
],
"company": {
"name": "TechCo",
"location": "San Francisco"
}
};
console.log(complexData);
Stringification
To convert a JavaScript object into a JSON string for transmission or
storage, use
JSON.stringify():
let jsonString =
JSON.stringify(complexData);
console.log(jsonString);
Parsing JSON:
To convert a JSON string back into a JavaScript object, use
JSON.parse():
let parsedObject = JSON.parse(jsonString);
console.log(parsedObject);
This covers the basics of creating, managing nesting, and handling complex data
structures with JSON objects in JavaScript, essential for web development and data
interchange scenarios.
Document Object Model (DOM) Manipulation
The DOM is:
Structured Representation: It represents the structure of a document as a tree of
objects, where each object corresponds to a part of the document.
Platform- and Language-Neutral: It provides a platform-neutral and language-neutral
interface, meaning it allows programs and scripts to dynamically access and update
the content, structure, and style of documents.
Dynamic: It allows JavaScript and other scripting languages to interact with the
structure and content of web pages, enabling dynamic updates and changes without
needing to reload the entire page.
Hierarchy: Elements in the document (such as elements, attributes, and text) are
organized in a hierarchical tree structure. Each node in the tree represents an object
corresponding to a part of the document.
DOM Manipulation:
DOM manipulation refers to the process of accessing or modifying
elements within the DOM tree using programming languages like
JavaScript. Developers commonly use DOM manipulation to
Update Content: Change text or attributes of elements.
Modify Structure: Add or remove elements dynamically.
Respond to Events: Attach event listeners to elements to respond to user
actions (e.g., clicks, inputs).
Animate Elements: Change CSS styles or properties to create animations
or transitions.
Example:
A basic example of how DOM manipulation works in JavaScript
<!DOCTYPE html>
<html>
<head>
<title>DOM Manipulation Example</title>
<script>
// JavaScript for DOM manipulation
document.addEventListener("DOMContentLoaded", function() {
// Find an element by id
let header = document.getElementById("main-header");
// Change its text content
header.textContent = "Updated Header";
// Create a new element
let newParagraph = document.createElement("p");
newParagraph.textContent = "This is a new paragraph.";
// Append it to the document
document.body.appendChild(newParagraph);
});
</script>
</head>
<body>
<h1 id="main-header">Original Header</h1>
</body>
</html>
In this example:
JavaScript accesses the <h1> element with id="main-header".
It changes the text content of this element.
It creates a new <p> element and appends it to the <body> of the document.
DOM manipulation is fundamental for creating interactive web
pages and web applications, allowing developers to dynamically
update and interact with page content based on user actions or
application logic.
Event Handling:
Adding Event Listeners:
Use addEventListener() method to attach event handlers to elements.
Syntax: element.addEventListener(eventType, handlerFunction);
const button =
document.getElementById('myButton');
button.addEventListener('click',
function(event) {
// Handle click event
});
Handling Events:
Common events include click, submit, keypress, etc.
Each event type triggers specific actions or behaviours.
Event Object and Event Propagation:
Accessing Event Properties:
Use the event object to access information about the event.
Example properties: event.target, event.preventDefault(), event.stopPropagation().
Understanding Event Propagation:
Event Bubbling: Events bubble up from the target element through
its ancestors.
Event Capturing: Events propagate down from the document root
to the target element.
AJAX (Asynchronous JavaScript and XML)
Introduction to AJAX:
Asynchronous Nature of JavaScript Requests:
Allows web pages to dynamically update content without reloading the entire page.
Enhances user experience by providing smoother and faster interactions.
Evolution from Traditional Synchronous Requests:
Traditional synchronous requests block the browser until the request completes.
AJAX enables asynchronous requests, allowing other operations to continue while waiting
for the response.
XMLHttpRequest Object:
Creating and Configuring XMLHttpRequest:
Core object for making asynchronous requests in JavaScript.
Methods: open(), send(), abort().
https://youtu.be/tNKD0kfel6o?si=OHECiO6EWKXb24er
Example
let xhr = new XMLHttpRequest();
xhr.open('GET', 'data.json', true);
xhr.send();
Sending GET and POST Requests:
GET requests retrieve data from a server.
POST requests send data to a server for processing.
Fetch API:
Modern Approach to AJAX with Fetch API:
Simplifies fetching resources asynchronously.
Returns a Promise that resolves to the response to the request.
Example:
fetch('data.json')
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error fetching data:', error));
Handling JSON Responses and Error Management:
Fetch API automatically parses JSON responses.
Handle errors using .catch() to manage network issues or failed requests.
Handling AJAX Responses
Using Callbacks, Promises (then, catch), and async/await:
Callbacks: Traditional approach for handling asynchronous operations.
Promises: Provides cleaner syntax for chaining asynchronous operations (then, catch).
Async/Await: Modern ES8 feature for synchronously writing asynchronous code.
Examples of Retrieving and Displaying Data Asynchronously:
Demonstrate fetching data from an API and updating the DOM dynamically based on the retrieved
data.
Web creation languages : Jason Learn Jason
Web creation languages : Jason Learn Jason

More Related Content

Similar to Web creation languages : Jason Learn Jason (20)

PDF
JSON Fuzzing: New approach to old problems
titanlambda
 
PPTX
Cordova training : Day 4 - Advanced Javascript
Binu Paul
 
PPTX
Working with XML and JSON Serializing
ssusere19c741
 
PPTX
Jason programming object oriented programming it- Updated.pptx
devmith2005
 
PPTX
Mule: JSON to Object
Sulthony Hartanto
 
PDF
JavaScript Lessons 2023 V2
Laurence Svekis ✔
 
PDF
Hands on JSON
Octavian Nadolu
 
PPTX
A Higher-Order Data Flow Model for Heterogeneous Big Data
Simon Price
 
PPTX
Silverlight week5
iedotnetug
 
PDF
Json
soumya
 
PPTX
Introduction to java script, how to include java in HTML
backiyalakshmi14
 
PPT
Javascript.ppt
NoralieNicol
 
PPTX
JSON
Yoga Raja
 
PPTX
NAVTechDays 2017 Json Meets NAV
Gunnar Gestsson
 
PPT
Java Script Based Client Server Webapps 2
kriszyp
 
PPTX
Web Development Introduction to jQuery
Laurence Svekis ✔
 
PPT
Advanced Json
guestfd7d7c
 
PPTX
Xsd restrictions, xsl elements, dhtml
AMIT VIRAMGAMI
 
PPTX
Introduction to JavaScript Object Notation(JSON)
gaikwaddavid2022
 
PDF
Intro to JSON
George McKinney
 
JSON Fuzzing: New approach to old problems
titanlambda
 
Cordova training : Day 4 - Advanced Javascript
Binu Paul
 
Working with XML and JSON Serializing
ssusere19c741
 
Jason programming object oriented programming it- Updated.pptx
devmith2005
 
Mule: JSON to Object
Sulthony Hartanto
 
JavaScript Lessons 2023 V2
Laurence Svekis ✔
 
Hands on JSON
Octavian Nadolu
 
A Higher-Order Data Flow Model for Heterogeneous Big Data
Simon Price
 
Silverlight week5
iedotnetug
 
Json
soumya
 
Introduction to java script, how to include java in HTML
backiyalakshmi14
 
Javascript.ppt
NoralieNicol
 
JSON
Yoga Raja
 
NAVTechDays 2017 Json Meets NAV
Gunnar Gestsson
 
Java Script Based Client Server Webapps 2
kriszyp
 
Web Development Introduction to jQuery
Laurence Svekis ✔
 
Advanced Json
guestfd7d7c
 
Xsd restrictions, xsl elements, dhtml
AMIT VIRAMGAMI
 
Introduction to JavaScript Object Notation(JSON)
gaikwaddavid2022
 
Intro to JSON
George McKinney
 

Recently uploaded (20)

PDF
CRAC- Adobe Photoshop CC 2016 (32 64Bit) Crack
utfefguu
 
PPTX
CompanyReviewTypeOfPowerpointThatIsColor
plukleomarigpuara
 
DOCX
Ai vehicle traffic signal detector research proposal.docx
DavidNameza
 
PPTX
Transportation in the air, sea and land.pptx
KhloodAli5
 
PPTX
BMC S6 M3 P1 building mATERIALS AND CONSTRUCTION.pptx
RizwanAlavi
 
PPTX
DEVELOPING-PARAGRAPHS.pptx-developing...
rania680036
 
PDF
Uber Driver Hackday Sprint Solving Ride Cancellations
YellowSlice1
 
PPTX
SAMPLE FILE OF-PPT-FINAL-ORAL-DEFENSE.pptx
Yvez2
 
PDF
S2 Associates brings museum exhibits to life with innovative design.pdf
S2 Associates
 
PDF
Case Study on good and bad acoustics in auditorium
Disha Agrawal
 
PPTX
condylar pptx.in relation to dental seurgery
abishekgowtham586
 
PPTX
619813902-Fun-friday-Identify-Bollywood-movie-from-dialogues-deliver-the-dial...
in4withme
 
PPTX
Visit Biogas Refresher Slide_Jun 2025.pptx
isyraffemir
 
PPTX
DIASS-DIAGNOSTIC-TEST.pptxnjkhbuyygygccd
mcsprima2023
 
PPTX
hall ppt 1 it for basic tamolet .pptx
ashishbehera64
 
PDF
The Role of Logos as Identity Shapers (IFIC Logo)
Md. Mehedi Hasan Asif
 
PDF
SS27 Men's Fashion Trend Book Peclers Paris
Peclers Paris
 
PDF
Black and Blue Modern Technology Presentation.pdf
hjaders1104
 
PPT
Javrhrbthtbryin6trtvrhnberra-without-BlueJ.ppt
jotola6956
 
DOCX
Ai Vehicle traffic signal detector Literature Review.
DavidNameza
 
CRAC- Adobe Photoshop CC 2016 (32 64Bit) Crack
utfefguu
 
CompanyReviewTypeOfPowerpointThatIsColor
plukleomarigpuara
 
Ai vehicle traffic signal detector research proposal.docx
DavidNameza
 
Transportation in the air, sea and land.pptx
KhloodAli5
 
BMC S6 M3 P1 building mATERIALS AND CONSTRUCTION.pptx
RizwanAlavi
 
DEVELOPING-PARAGRAPHS.pptx-developing...
rania680036
 
Uber Driver Hackday Sprint Solving Ride Cancellations
YellowSlice1
 
SAMPLE FILE OF-PPT-FINAL-ORAL-DEFENSE.pptx
Yvez2
 
S2 Associates brings museum exhibits to life with innovative design.pdf
S2 Associates
 
Case Study on good and bad acoustics in auditorium
Disha Agrawal
 
condylar pptx.in relation to dental seurgery
abishekgowtham586
 
619813902-Fun-friday-Identify-Bollywood-movie-from-dialogues-deliver-the-dial...
in4withme
 
Visit Biogas Refresher Slide_Jun 2025.pptx
isyraffemir
 
DIASS-DIAGNOSTIC-TEST.pptxnjkhbuyygygccd
mcsprima2023
 
hall ppt 1 it for basic tamolet .pptx
ashishbehera64
 
The Role of Logos as Identity Shapers (IFIC Logo)
Md. Mehedi Hasan Asif
 
SS27 Men's Fashion Trend Book Peclers Paris
Peclers Paris
 
Black and Blue Modern Technology Presentation.pdf
hjaders1104
 
Javrhrbthtbryin6trtvrhnberra-without-BlueJ.ppt
jotola6956
 
Ai Vehicle traffic signal detector Literature Review.
DavidNameza
 
Ad

Web creation languages : Jason Learn Jason

  • 2. JSON - JavaScript Object Notation is a lightweight data-interchange format that is easy for humans to read and write and easy for machines to parse and generate. Syntax: JSON syntax is derived from JavaScript object notation syntax: Data Types: JSON supports primitive data types like strings, numbers, booleans, and null, as well as complex data types like arrays and objects. Format: Data is represented in key-value pairs. Keys must be strings enclosed in double quotes, and values can be any valid JSON data type. https://youtu.be/iiADhChRriM?si=y_whC20WOnxNDjco Introduction to JSON
  • 4. Example: { "name": "John Doe", "age": 30, "isStudent": false, "courses": ["Math", "Science"], "address": { "city": "New York", "zipCode": "10001" } }
  • 5. Data Format Text-Based: JSON data is stored as plain text, making it easy to transmit and store. Hierarchy: Supports nested structures using arrays and objects, allowing complex data relationships to be represented. Platform Independence: Widely supported across programming languages and platforms, making it ideal for interoperability.
  • 6. Use Cases: JSON is commonly used for: APIs: Many web APIs use JSON for data interchange between servers and clients. Configuration Files: Often used for configuration settings due to its simplicity and readability. Data Storage: Storing and transmitting structured data in web applications and databases. Serialization: Converting objects into JSON format for transmission or storage, and deserialization vice versa. JSON's simplicity, readability, and flexibility make it a popular choice for exchanging data between systems and applications on the web.
  • 7. Creating JSON objects in JavaScript involves defining and structuring data using JavaScript syntax, which closely resembles the JSON format itself. Here’s how you can create and manage JSON objects, including nesting and handling complex data structures: JSON Objects
  • 8. Basic JSON Object Creation: You can create a JSON object directly in JavaScript by defining it as a JavaScript object literal enclosed in curly braces { } // Define a JSON object let person = { "name": "John Doe", "age": 30, "isStudent": false, "courses": ["Math", "Science"], "address": { "city": "New York", "zipCode": "10001" } }; console.log(person);
  • 9. Managing Nesting: JSON supports nested objects and arrays, allowing you to represent hierarchical data structures // Nested JSON object let nestedObject = { "name": "John Doe", "contacts": [ { "type": "email", "value": "[email protected]" }, { "type": "phone", "value": "123-456-7890" } ], "address": { "city": "New York", "zipCode": "10001" } };
  • 10. Dynamically Creating JSON: You can dynamically add properties and values to a JSON object using JavaScript’s object notation // Dynamic JSON creation let dynamicObject = {}; dynamicObject.name = "Jane Smith"; dynamicObject.age = 25; dynamicObject.skills = ["JavaScript", "HTML", "CSS"]; dynamicObject.address = { "city": "San Francisco", "zipCode": "94105" }; console.log(dynamicObject);
  • 11. Complex Data Structures: JSON in JavaScript can handle complex data structures such as arrays of objects or nested objects within arrays // Complex JSON structure let complexData = { "employees": [ { "name": "Alice", "department": "Engineering", "skills": ["JavaScript", "Python"] }, { "name": "Bob", "department": "Marketing", "skills": ["SEO", "Social Media"] } ], "company": { "name": "TechCo", "location": "San Francisco" } }; console.log(complexData);
  • 12. Stringification To convert a JavaScript object into a JSON string for transmission or storage, use JSON.stringify(): let jsonString = JSON.stringify(complexData); console.log(jsonString);
  • 13. Parsing JSON: To convert a JSON string back into a JavaScript object, use JSON.parse(): let parsedObject = JSON.parse(jsonString); console.log(parsedObject); This covers the basics of creating, managing nesting, and handling complex data structures with JSON objects in JavaScript, essential for web development and data interchange scenarios.
  • 14. Document Object Model (DOM) Manipulation The DOM is: Structured Representation: It represents the structure of a document as a tree of objects, where each object corresponds to a part of the document. Platform- and Language-Neutral: It provides a platform-neutral and language-neutral interface, meaning it allows programs and scripts to dynamically access and update the content, structure, and style of documents. Dynamic: It allows JavaScript and other scripting languages to interact with the structure and content of web pages, enabling dynamic updates and changes without needing to reload the entire page. Hierarchy: Elements in the document (such as elements, attributes, and text) are organized in a hierarchical tree structure. Each node in the tree represents an object corresponding to a part of the document.
  • 15. DOM Manipulation: DOM manipulation refers to the process of accessing or modifying elements within the DOM tree using programming languages like JavaScript. Developers commonly use DOM manipulation to Update Content: Change text or attributes of elements. Modify Structure: Add or remove elements dynamically. Respond to Events: Attach event listeners to elements to respond to user actions (e.g., clicks, inputs). Animate Elements: Change CSS styles or properties to create animations or transitions.
  • 16. Example: A basic example of how DOM manipulation works in JavaScript <!DOCTYPE html> <html> <head> <title>DOM Manipulation Example</title> <script> // JavaScript for DOM manipulation document.addEventListener("DOMContentLoaded", function() { // Find an element by id let header = document.getElementById("main-header"); // Change its text content header.textContent = "Updated Header"; // Create a new element let newParagraph = document.createElement("p"); newParagraph.textContent = "This is a new paragraph."; // Append it to the document document.body.appendChild(newParagraph); }); </script> </head> <body> <h1 id="main-header">Original Header</h1> </body> </html>
  • 17. In this example: JavaScript accesses the <h1> element with id="main-header". It changes the text content of this element. It creates a new <p> element and appends it to the <body> of the document. DOM manipulation is fundamental for creating interactive web pages and web applications, allowing developers to dynamically update and interact with page content based on user actions or application logic.
  • 18. Event Handling: Adding Event Listeners: Use addEventListener() method to attach event handlers to elements. Syntax: element.addEventListener(eventType, handlerFunction); const button = document.getElementById('myButton'); button.addEventListener('click', function(event) { // Handle click event }); Handling Events: Common events include click, submit, keypress, etc. Each event type triggers specific actions or behaviours.
  • 19. Event Object and Event Propagation: Accessing Event Properties: Use the event object to access information about the event. Example properties: event.target, event.preventDefault(), event.stopPropagation(). Understanding Event Propagation: Event Bubbling: Events bubble up from the target element through its ancestors. Event Capturing: Events propagate down from the document root to the target element.
  • 20. AJAX (Asynchronous JavaScript and XML) Introduction to AJAX: Asynchronous Nature of JavaScript Requests: Allows web pages to dynamically update content without reloading the entire page. Enhances user experience by providing smoother and faster interactions. Evolution from Traditional Synchronous Requests: Traditional synchronous requests block the browser until the request completes. AJAX enables asynchronous requests, allowing other operations to continue while waiting for the response. XMLHttpRequest Object: Creating and Configuring XMLHttpRequest: Core object for making asynchronous requests in JavaScript. Methods: open(), send(), abort(). https://youtu.be/tNKD0kfel6o?si=OHECiO6EWKXb24er
  • 21. Example let xhr = new XMLHttpRequest(); xhr.open('GET', 'data.json', true); xhr.send(); Sending GET and POST Requests: GET requests retrieve data from a server. POST requests send data to a server for processing.
  • 22. Fetch API: Modern Approach to AJAX with Fetch API: Simplifies fetching resources asynchronously. Returns a Promise that resolves to the response to the request. Example: fetch('data.json') .then(response => response.json()) .then(data => console.log(data)) .catch(error => console.error('Error fetching data:', error)); Handling JSON Responses and Error Management: Fetch API automatically parses JSON responses. Handle errors using .catch() to manage network issues or failed requests.
  • 23. Handling AJAX Responses Using Callbacks, Promises (then, catch), and async/await: Callbacks: Traditional approach for handling asynchronous operations. Promises: Provides cleaner syntax for chaining asynchronous operations (then, catch). Async/Await: Modern ES8 feature for synchronously writing asynchronous code. Examples of Retrieving and Displaying Data Asynchronously: Demonstrate fetching data from an API and updating the DOM dynamically based on the retrieved data.

Editor's Notes

  • #22: Handling JSON Responses and Error Management: Fetch API automatically parses JSON responses. Handle errors using .catch() to manage network issues or failed requests.