darjun / blog-comments

博客评论
0 stars 0 forks source link

2020/07/29/godailylib/mapstructure/ #22

Open utterances-bot opened 2 years ago

utterances-bot commented 2 years ago

Go 每日一库之 mapstructure - 大俊的博客

简介 mapstructure用于将通用的map[string]interface{}解码到对应的 Go 结构体中,或者执行相反的操作。很多时候,解

https://darjun.github.io/2020/07/29/godailylib/mapstructure/

AnkoGo123 commented 2 years ago

自定义解码器用于解码time.Time类型,缺少应用的例子没有什么用,这个库最难用的还是 从map 的time类型字段解码到多层的struct中去。,

AnkoGo123 commented 2 years ago

time字符串解码成为struct time类型。

yangpan12138 commented 2 years ago

jsonschema 无法解析,请教一下要如何处理结构体中存在 jsonschema 的类型?

ChocolateAceCream commented 1 year ago

WeakDecode那里有个问题, m := map[string]interface{}{ "name": 123, "age": true "emails": []int{1, 2, 3}, } 这样居然是可以被weakdecode的, boolean居然是可以被weakdeocde转化成int的? decode的结果是 decode data: map[age:false job:programmer name:dsdj] 不科学啊