方案
struct与map之间的转换,通过json.Marshal(interface{})
与json.Unmarshal([]byte,interface{})
.
亦或者通过第三方库来转换:
map转struct:https://github.com/mitchellh/mapstructure
struct转map:https://github.com/fatih/structs
参考
golang中struct、json、map互相转化
GO学习-(38) Go语言结构体转map[string]interface{}的若干方法