I have a simple struct with string and int. When I unmarshal a json the struct members are not getting parsed if beginning with lowercase string .Even if I am using in the same package
package main
import (
"encoding/json"
"fmt"
)
type Bird struct {
Species string
Description string
lifespan int
}
func main() {
birdJson := `{"species": "pigeon","description": "likes to perch on rocks","lifespan": 9}`
var bird Bird
json.Unmarshal([]byte(birdJson), &bird)
fmt.Printf("Species: %s, Description: %s,lifespan: %d", bird.Species, bird.Description,bird.lifespan)
//Cant read the lifespan ??
}