结构体 字典 json 序列化 差异
实践:
1、
import "encoding/json"
func mapVstruct2jsonMarshal() {
t := struct {
A string
B int32
C bool
}{"a", 123, true}
m := map[string]interface{}{
"A": "a",
"B": 123,
"C": true,
}
b1, _ := json.Marshal(t)
b2, _ := json.Marshal(m)
t := map[string]interface{}{
"app_key": app_key,
"version": version,
"timestamp": timestamp_int,
"nonce_str": nonce_str,
"sign": sign,
}
p, _ := json.Marshal(t)
https://mp.weixin.qq.com/s/dvLzS3t51Hq_fPK1FkumyQ