Solution Review: Process JSON Data
Understand the solution for the 'Process JSON Data' challenge.
We'll cover the following
Solution overview
To complete the challenge, we need to first understand the format and structure of the JSON data and unmarshal it. Once the JSON data is in a workable format, we iterate through the items to find the most expensive one.
The getMostExpensive
function receives a string as an argument and returns a string. We'll first unmarshal the JSON received into a slice. We'll create a variable that'll keep track of the highest Price
of the items provided, which we calculate by iterating through the slice and comparing the values.
Finally, we'll marshal the string back into JSON format and return it.
Code
The complete code for this challenge is provided below.
Get hands-on with 1400+ tech skills courses.