Question: 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

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!