Question: Write a Java program that reads a JSON file containing a list of students. Each student has a name, age, and major. The program should:

Write a Java program that reads a JSON file containing a list of students. Each student has a name, age, and major. The program should:
Deserialize the JSON data into a list of Student objects. Print each student's details to the console. Modify the list by adding a new student and then serialize the updated list back to a new JSON file.
JSON file: [
{
"student": {
"id": 1,
"name": "Alice",
"age": 20,
"major": "Computer Science"
}
},
{
"student": {
"id": 2,
"name": "Bob",
"age": 22,
"major": "Mathematics"
}
},
{
"student": {
"id": 3,
"name": "Charlie",
"age": 19,
"major": "Physics"
}
},
{
"student": {
"id": 4,
"name": "David",
"age": 21,
"major": "Biology"
}
},
{
"student": {
"id": 5,
"name": "Eve",
"age": 20,
"major": "Chemistry"
}
},
{
"student": {
"id": 6,
"name": "Frank",
"age": 23,
"major": "Electrical Engineering"
}
},
{
"student": {
"id": 7,
"name": "Grace",
"age": 22,
"major": "Mechanical Engineering"
}
},
{
"student": {
"id": 8,
"name": "Hannah",
"age": 21,
"major": "Environmental Science"
}
},
{
"student": {
"id": 9,
"name": "Ian",
"age": 24,
"major": "Business Administration"
}
},
{
"student": {
"id": 10,
"name": "Judy",
"age": 20,
"major": "Information Technology"
}
}
]

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!