




Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
What is JSON? JSON stands for JavaScript Object Notation. This is a lightweight, flexible yet strict method of storing and transmitting data.
Typology: Exercises
1 / 8
This page cannot be seen from the preview
Don't miss anything!
What is JSON?
JSON stands for JavaScript Object Notation. This is a lightweight, flexible yet strict method of storing and transmitting data. Flexible in that the user can create the format and names in any way they please; strict in the sense that JSON has a strict set of rules for structure.
A JavaScript object is a series of name/value pairs, written in a structured way. The basic structure is:
{name:value,name:value,name:value}
Generic Rules to be followed while creating a JSON:
JSON Objects should start and end with braces “{ }”. Key fields are included in the double quotes. Values are represented by putting “:” colon between them and the keys. JSON key-value pairs are separated by a comma “,”. Values can be of any data type like String, Integer, Boolean etc.
Basic JSON file
Let’s assume we have a car object with the following basic properties and their attributes:
Make and Mode = Maruti Suzuki Swift Make Year = 2017 Color = Red Type = Hatchback
So, if we want to transfer this data using a JSON file, then the serialization of this data will create a JSON.
That JSON will look something like this:
JSON Arrays
The array starts with a left square bracket “[“and ends with right square bracket “]”. The values inside the array are separated by a comma.
In order to include the car in the Employee JSON, initially, we need to include a Key as “car” in the JSON.
Something like this:
Once we have added the car key in the employee JSON, we can then pass the value directly to the Car JSON. In this way, we can create a Nested JSON.
Something like this:
Tutorial 2 JQuery to retrieve a .txt file via HTTP, then output it to a web page.
artists.txt
Tutorial 3 Update the Tutorial 2 code to use AJAX method with JQuery to retrieve a JSON file, then output it to a web page.
artists.json Output:
Tutorial 4 HTML Table using Ajax JQuery getJSON method
index.html
employee.json Output:
Tutorial 5 Update Tutorial 4 - getJSON method to get JASON contains imageURL
index.html
employee.json Output: