settings: Convert JSON strings to the given type
This commit is contained in:
parent
95aadffb2e
commit
8aba067d05
|
@ -110,6 +110,13 @@ func MergeSettings(current Settings, new map[string]interface{}) *Settings {
|
||||||
}
|
}
|
||||||
|
|
||||||
if v, ok := new[name]; ok {
|
if v, ok := new[name]; ok {
|
||||||
|
if reflect.TypeOf(v) != reflect.ValueOf(¤t).Elem().FieldByName(field.Name).Type() {
|
||||||
|
nv := reflect.New(reflect.ValueOf(¤t).Elem().FieldByName(field.Name).Type())
|
||||||
|
mv, _ := json.Marshal(v)
|
||||||
|
json.Unmarshal(mv, nv.Interface())
|
||||||
|
v = nv.Elem().Interface()
|
||||||
|
}
|
||||||
|
|
||||||
reflect.ValueOf(¤t).Elem().FieldByName(field.Name).Set(reflect.ValueOf(v))
|
reflect.ValueOf(¤t).Elem().FieldByName(field.Name).Set(reflect.ValueOf(v))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue