试图将字符串解组为 json,但我的结构定义不起作用。如何修复?
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)
}
}
明月笑刀无情
红糖糍粑
相关分类