这种写法是什么意思

cups_book · · 1202 次点击
谢谢🙏 Unmarshal parses the JSON-encoded data and stores the result in the value pointed to by v. If v is nil or not a pointer, Unmarshal returns an InvalidUnmarshalError. ```go package main import ( "fmt" "encoding/json" ) type User struct { Name string "name"//结构的字段可以带标签字面量,成为字段的属性 Pass string "pass" Age int16 "age" } func main() { var json_string = `{"name":"zhangsan","pass":"123456","age":20}` // usr := &User{} var usr = new (User) json.Unmarshal([]byte(json_string), usr)//解析json字符串 fmt.Println(usr) } ```
#5
更多评论
go结构体标签 https://blog.csdn.net/benben_2015/article/details/79807792
#1
嗯,我遇到的是这个错误: json: cannot unmarshal array into Go struct field 意思是说...go没法反序列化一个array到go的结构体字段里去..?
#2