则无 text 序列 nbsp text2 main mar type
- type temp struct {
- Afd int
- Bee string
- }
- func main() {text: =temp {
- 3123,
- "4234"
- }b._: =json.Marshal(text) var text2 temperr: =json.Unmarshal(b, &text2)fmt.Println(err, text2)
- }
- temp结构体内的Afd和Bee首字母一定大写,否则无法序列化和反序列化
struct 和 []byte 的转换,注意结构体内变量首字母一定大写
来源: http://www.bubuko.com/infodetail-2229137.html