2020
12-22
12-22
golang 实现struct、json、map互相转化
一、Json和struct互换(1)Json转struct例子:packagemainimport("fmt""encoding/json")typePeoplestruct{Namestring`json:"name_title"`Ageint`json:"age_size"`}funcJsonToStructDemo(){jsonStr:=`{"name_title":"jqw""age_size":12}`varpeoplePeoplejson.Unmarshal([]byte(jsonStr),&people)fmt.Println(people)}funcmain(){JsonToStruc...
继续阅读 >