Commit a97c7cc0 authored by earncef's avatar earncef Committed by Hanzei
Browse files

Fixed incorrect result for obj.Value().MSI() getter (#65)

* Fixed incorrect result for obj.Value().MSI() getter

* Cleanup

* Added todo for a better fix.

* Restored  indentation.

* Fix indentation
parent 25326337
......@@ -131,10 +131,14 @@ func (v *Value) CollectInter(collector func(int, interface{}) interface{}) *Valu
// MSI gets the value as a map[string]interface{}, returns the optionalDefault
// value or a system default object if the value is the wrong type.
// TODO: Find a better solution for the Map type as this code is autogenerated
func (v *Value) MSI(optionalDefault[string]interface{}) map[string]interface{} {
if s, ok :=[string]interface{}); ok {
return s
if s, ok :=; ok {
return map[string]interface{}(s)
if len(optionalDefault) == 1 {
return optionalDefault[0]
......@@ -136,6 +136,7 @@ func TestMSI(t *testing.T) {
val := map[string]interface{}(map[string]interface{}{"name": "Tyler"})
m := objx.Map{"value": val, "nothing": nil}
assert.Equal(t, map[string]interface{}{"value": val, "nothing": nil}, m.Value().MSI())
assert.Equal(t, val, m.Get("value").MSI())
assert.Equal(t, val, m.Get("value").MustMSI())
assert.Equal(t, map[string]interface{}(nil), m.Get("nothing").MSI())
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment