Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

JAVA The application uses gson-2.8.6.jar (or later), and must include that jar file in the zip file you submit to Canvas The application has at

JAVA

  1. The application uses gson-2.8.6.jar (or later), andmust include that jar file in the zip file you submit to Canvas
  2. The application has at least the following four source-code files: StudentInfoGsonApp.java, Student.java, StudentList.java, PhoneNumber.java
  3. The main method in StudentInfoGsonApp does the following:
  • creates the studentInfo String array as follows:

o String[] studentInfo = {\"John, Doe, 3.1, 800-555-1212, Solidity\",

o \"Jane, Deere, 3.25, 898-555-1212, swimming;sleeping;dreaming;kayaking;\",

o \"Sam, Spade, 2.9, 888-555-1212, coffee-drinking;Java;Python\"};

  • creates a new StudentList object and populates that StudentList object with three Student objects that take their values from studentInfo array above. Make sure that the phoneNumber in a Student object is a reference to a PhoneNumber object, not just a String, and that that skills variable in a Student is anarrayof Strings (the skills)).
  • creates a new Gson object (ready for pretty printing) and uses a method of that object to convert your StudentList object to a JSON String.
  • converts that JSON String back to a *new* StudentList object
  • creates a new JsonObject called \"jane\" and adds all of the information in for Student Jane Deere to that JsonObject
  • prints the output below by: 1) pretty-printing the first JSON String created above; 2) iterating through the new StudentList object you created to print its values; and 3) printing the values for Student Jane Deere

o {

o \"students\": [

o {

o \"firstName\": \"John\",

o \"lastName\": \"Doe\",

o \"gpa\": 3.1,

o \"phoneNumber\": {

o \"areaCode\": 800,

o \"prefix\": 555,

o \"lineNum\": 1212

o },

o \"skills\": [

o \"Solidity\"

o ]

o },

o {

o \"firstName\": \"Jane\",

o \"lastName\": \"Deere\",

o \"gpa\": 3.25,

o \"phoneNumber\": {

o \"areaCode\": 898,

o \"prefix\": 555,

o \"lineNum\": 1212

o },

o \"skills\": [

o \"swimming\",

o \"sleeping\",

o \"dreaming\",

o \"kayaking\"

o ]

o },

o {

o \"firstName\": \"Sam\",

o \"lastName\": \"Spade\",

o \"gpa\": 2.9,

o \"phoneNumber\": {

o \"areaCode\": 888,

o \"prefix\": 555,

o \"lineNum\": 1212

o },

o \"skills\": [

o \"coffee-drinking\",

o \"Java\",

o \"Python\"

o ]

o }

o ]

o }

o

o [firstName: John, lastName: Doe, gpa: 3.1, phoneNumber=800-555-1212, skills: [Solidity]]

o [firstName: Jane, lastName: Deere, gpa: 3.25, phoneNumber=898-555-1212, skills: [swimming,sleeping,dreaming,kayaking]]

o [firstName: Sam, lastName: Spade, gpa: 2.9, phoneNumber=888-555-1212, skills: [coffee-drinking,Java,Python]]

o

{\"firstName\":\"Jane\",\"lastName\":\"Deere\",\"areaCode\":898,\"skills\":\"[swimming, sleeping, dreaming, kayaking]\"}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction to Wireless and Mobile Systems

Authors: Dharma P. Agrawal, Qing An Zeng

4th edition

1305087135, 978-1305087132, 9781305259621, 1305259629, 9781305537910 , 978-130508713

More Books

Students also viewed these Programming questions

Question

What is management growth? What are its factors

Answered: 1 week ago