标签:string bsp err byte bytes mars return turn 结构体
package main import ( "encoding/json" "fmt" ) type Persion struct { Name string Age int Rmb float64 Sex bool Hobby []string } func main() {
persion := Persion{"谦哥", 50, 123.45, true, []string{"抽烟", "喝酒", "烫头"}} //使用json包序列化结构体 bytes, e := json.Marshal(persion) if e != nil { fmt.Printf("序列化失败,err=",e) return } fmt.Println(string(bytes)) }
标签:string bsp err byte bytes mars return turn 结构体
原文地址:https://www.cnblogs.com/paad/p/11249983.html