Trying to unmarshal a string into json, but my struct definitions don't work. How can it be fixed?
package main
import "fmt"
import "encoding/json"
func main() {
x := `{
"Header": {
"Encoding-Type": [
"gzip"
],
"Bytes": [
"29"
]
}
}`
type HeaderStruct struct {
A string
B []string
}
type Foo struct {
Header HeaderStruct
}
var f Foo
if e := json.Unmarshal([]byte(x), &f); e != nil {
fmt.Println("Failed:", e)
} else {
fmt.Println("unmarshalled=", f)
}
}