国外设计网站pinterest极速版,免费虚拟主机空间互联,杭州余杭网站建设,谷歌浏览器下载官网问题#xff1a;数据结构中的值 带有 等符号#xff0c;当我们要将 struct map 转成json时#xff0c;使用
json.Marshal() 函数#xff0c;此函数会将 值中的 符号转义 为 类似 \u0026
像我们某个结构体中…问题数据结构中的值 带有 等符号当我们要将 struct map 转成json时使用
json.Marshal() 函数此函数会将 值中的 符号转义 为 类似 \u0026
像我们某个结构体中携带了 路径及参数 http://baidu.com?a123b456,那么转义了就会出错 解决办法
parm : make(map[string]string)
parm[path] http://baidu.com?adjflksb1231131//转成json 不转义特殊字符
bf : bytes.NewBuffer([]byte{})
jsonEncoder : json.NewEncoder(bf)
jsonEncoder.SetEscapeHTML(false)
jsonEncoder.Encode(parm)
fmt.Println(bf.String())