Table of Contents
JSON Example
Assignment 1: Develop a JSON Data which shows data of students from three different sections of a class. Data must include students name and their favourite subjects. Display the data in a table.
Solution: In this assignment, we will initially have a JSON with three objects (represented by {}). These objects will represent three different sections, so we will name these objects as A, B and C.
Under these objects, we will have an array. An array (represented by []) can hold multiple records. Thus, we will have multiple students record under each array.
Each individual record for a student is also unique, therefore every student information will also be represented using an object. Here, we have added only three students (objects) in each section.
If I add three students in place of three empty objects, it will look something like this:
Since, these objects represent students’ detail, therefore I named them students. Under this object, we will have another array (here, fav sub) that will represent their favourite subjects.
If we add all the subjects in the given array, fav sub. Then, it will look something like this:
Now, we will validate the above JSON code using the validator. Our JSON will produce output something like this (not exactly, we have added section to make it look better):
JSON Assignment
Assignment 2: Develop a JSON Data which shows data of 10 Employees. It will include Employee ID, Employee Name, Date of Joining and their location. The output must look something like this (but with 10 record):
Note: You can use online JSON to HTML converter to check output in the form of a table.
0 Comments