v0.0.428
Some checks failed
Build Docker and Deploy / Run goext test-suite (push) Has been cancelled
Some checks failed
Build Docker and Deploy / Run goext test-suite (push) Has been cancelled
This commit is contained in:
@@ -2,6 +2,7 @@ package reflectext
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"gogs.mikescher.com/BlackForestBytes/goext/langext"
|
||||
"reflect"
|
||||
)
|
||||
|
||||
@@ -14,7 +15,16 @@ func ConvertStructToMap(v any, opts ...ConvertStructToMapOpt) any {
|
||||
if len(opts) > 0 {
|
||||
opt = opts[0]
|
||||
}
|
||||
return reflectToMap(reflect.ValueOf(v), opt)
|
||||
|
||||
res := reflectToMap(reflect.ValueOf(v), opt)
|
||||
|
||||
if v, ok := res.(map[string]any); ok {
|
||||
return v
|
||||
} else if langext.IsNil(res) {
|
||||
return nil
|
||||
} else {
|
||||
panic("not an object")
|
||||
}
|
||||
}
|
||||
|
||||
func reflectToMap(fv reflect.Value, opt ConvertStructToMapOpt) any {
|
||||
|
Reference in New Issue
Block a user