func main() {
src := `{"iss":"magic-ios-1.0.0","iat":1487000471,"jti":"4861ed10","rbd":"dbac2c5f","uri":"/auth/hello","ttu":""}`
var params interface{}
err := json.Unmarshal([]byte(src), ¶ms)
if err != nil {
fmt.Printf("%v\n", err)
return
}
p, _ := json.Marshal(params)
fmt.Printf("%v, %s\n", params, p)
}
问题描述:
- json原始字符串
src := {"iss":"magic-ios-1.0.0","iat":1487000471,"jti":"4861ed10","rbd":"dbac2c5f","uri":"/auth /hello","ttu":""}
- 经过json.Unmarshal,再次 json.Marshal的输出结果与原始字符串不一致,如下:
map[iss:magic-ios-1.0.0 iat:1.487000471e+09 jti:4861ed10 rbd:dbac2c5f uri:/auth/hello ttu:], {"iat":1.487000471e+09,"iss":"magic-ios-1.0.0","jti":"4861ed10","rbd":"dbac2c5f","ttu":"","uri":"/auth/hello"}
有人遇到这种问题嘛?json串字段顺序变了,原始字符串md5值与一次转换后的字符串md5值就不一致了。