Using the attached Java classes (Car.java and Wheel.java) as a guide, create a r
ID: 3731076 • Letter: U
Question
Using the attached Java classes (Car.java and Wheel.java) as a guide, create a representative JSON string that might be produced upon serialization of a Car object. You are free to populate the Car and Wheel object properties with any data you like.
------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------
Explanation / Answer
Car{
"make":"BMW",
"model":"X1",
"year":2015,
"price":15000,
"wheels" : [
{"make":"apolo","model":"C1","width":17,"aspectRatio ": 90,"diameter" : 19,"loadIndex:15},
{"make":"apolo","model":"C2","width":18,"aspectRatio ": 90,"diameter" : 19,"loadIndex:15}
]
}
Since Wheels is an array of object the resulting JSON will have a array of WHEEL object which is included with in [] as per JSON specification.
Each member variable in the class will have an entry in the JSON seperated by the comma and values of the member variable will be encolosed with in the "" if its not a numeric type.
JSON will have Key and Valye pair format. i.e
MEMBERVARIABLE : VALUE
So for example make will have the following entry
"make" : "BMW"
The left to the : is member variable and to the right of colon is value
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.