{ total: 100, rows: [{ goodId: "4893ed8518ff41268baf5a2f7f3e5398", reportedStaffid: "", reportedName: "", reportedPst: "", reportedOrg: "", reportedTime: "", goodTitle: "", goodContent: "", reportStaffid: "", reportName: "", reportPst: "", reportOrg: "", publishRange: "", praiseCnt: "", commentCnt: "0", }] }
如上串
方法1:
js = strings.Replace(js,`{`,`{"`,-1) js = strings.Replace(js ,`:`,`":`,-1) js = strings.Replace(js,`,`,`,"`,-1) js = strings.Replace(js,`,"{`,`,{`,-1) fmt.Println(js) unmarshal := make(map[string]interface{}) err := json.Unmarshal([]byte(js), &unmarshal) if err != nil { panic(err) } fmt.Println(unmarshal)
方法2:
reg:=regexp.MustCompile(`[\w]+[:]`) reg.ReplaceAllStringFunc(resStr,func(s string) string{ reg2:=regexp.MustCompile(`[\w]+`) s=reg2.FindAllString(s,-1)[0] return `"`+s+`":` })
欢迎来到这里!
我们正在构建一个小众社区,大家在这里相互信任,以平等 • 自由 • 奔放的价值观进行分享交流。最终,希望大家能够找到与自己志同道合的伙伴,共同成长。
注册 关于