golang结构体与json格式串实例代码
å·ä½ä»£ç å¦ä¸æ示ï¼
package main import ( "encoding/json" "fmt" ) type IT struct { //ä¸å®è¦æ³¨æè¿éçæååéçååé¦åæ¯å¿é¡»æ¯å¤§å Company string Subjects []string Isok bool Price float64 } func main() { s := IT{"zyg", []string{"go", "python", "java"}, true, 3.14} buf, err := json.Marshal(s) if err != nil { fmt.Println("err = ", err) return } fmt.Println("buf = ", string(buf)) buf, err = json.MarshalIndent(s, "", " ") // å°jsonå½¢å¼çå符串è¿è¡æ ¼å¼å fmt.Println(string(buf)) }
Isok bool json:",string" å°Isok è¿è¡äºæ¬¡ç¼ç å¾å°å¸å°çå符串string
æ»ç»
以ä¸æè¿°æ¯å°ç¼ç»å¤§å®¶ä»ç»çgolangç»æä½ä¸jsonæ ¼å¼ä¸²å®ä¾ä»£ç ï¼å¸æ对大家ææ帮å©ï¼å¦æ大家æä»»ä½çé®æ¬¢è¿ç»æçè¨ï¼å°ç¼ä¼åæ¶åå¤å¤§å®¶çï¼
相关推荐
Lzs 2020-10-23
Justhavefun 2020-10-22
周游列国之仕子 2020-09-15
风雨断肠人 2020-09-04
聚合室 2020-11-16
零 2020-09-18
jacktangj 2020-10-14
ChaITSimpleLove 2020-10-06
Andrea0 2020-09-18
afanti 2020-09-16
88234852 2020-09-15
YClimb 2020-09-15
卖口粥湛蓝的天空 2020-09-15
stulen 2020-09-15
pythonxuexi 2020-09-06
abfdada 2020-08-26
梦的天空 2020-08-25