You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
19 lines
283 B
Go
19 lines
283 B
Go
5 years ago
|
package utils
|
||
|
|
||
|
import (
|
||
|
"git.sp4ke.com/sp4ke/hugobot/v3/types"
|
||
|
|
||
|
"github.com/fatih/structs"
|
||
|
)
|
||
|
|
||
|
func StructToJsonMap(in interface{}) types.JsonMap {
|
||
|
out := make(types.JsonMap)
|
||
|
|
||
|
s := structs.New(in)
|
||
|
for _, f := range s.Fields() {
|
||
|
out[f.Tag("json")] = f.Value()
|
||
|
}
|
||
|
|
||
|
return out
|
||
|
}
|