When parsing JSON with Go, is it possible to fail if a value is null or missing, without having to check every single field via an if statement? For example:
package main
import (
"encoding/json"
"fmt"
)
type Bird struct {
Species string `json:"birdType"`
Description string `json:"what it does"`
}
func main() {
birdJson := `{"birdType": "pigeon"}`
var bird Bird
json.Unmarshal([]byte(birdJson), &bird)
fmt.Println(bird)
}
I'd expect to raise an error since "what it does"
is not defined