3. Unmarshal JSON
Example
// res is an http.Response
defer res.Body.Close()
data, err := io.ReadAll(res.Body)
if err != nil {
return nil, err
}
var issues []Issue
if err := json.Unmarshal(data, &issues); err != nil {
return nil, err
}Understanding Unmarshal vs Decoder
decoder := json.NewDecoder(res.Body)
decoder.Decode(&issues)The Solution
Step-by-Step Breakdown
Complete Working Code
The Flow
Comparison: Decoder vs Unmarshal
Using Decoder (from previous lesson)
Using Unmarshal (this lesson)
When to Use Each
Key Takeaways
Assignment
1
2
3
4
5
6