Working on Json Unmarshal/marshal capabilities in Go-lang. Ran into the below exercise from Go playground link
package main
import (
"encoding/json"
"fmt"
)
type Bird struct {
Species string
Description string
}
func main() {
birdJson := `[{"species":"pigeon","decription":"likes to perch on rocks"},{"species":"eagle","description":"bird of prey"}]`
var birds []Bird
json.Unmarshal([]byte(birdJson), &birds)
fmt.Printf("Birds : %+v", birds)
//Birds : [{Species:pigeon Description:} {Species:eagle Description:bird of prey}]
}
This statement, fmt.Printf("Birds : %+v", birds)
, should return the outcome where it prints the description of first element in the json but as you can see it just prints description and moves on to print next json element.
I am unable to reason why would that happen. This is the link to original article.