Commit e89b2c16 authored by Andrey's avatar Andrey Committed by Hanzei
Browse files

Fix ObjxMapSlice (#17)

parent ca93b98c
......@@ -276,13 +276,21 @@ func (v *Value) MustObjxMap() Map {
// ObjxMapSlice gets the value as a [](Map), returns the optionalDefault
// value or nil if the value is not a [](Map).
func (v *Value) ObjxMapSlice(optionalDefault ...[](Map)) [](Map) {
if s, ok := v.data.([](Map)); ok {
return s
slice, ok := v.data.([]interface{})
if !ok {
if len(optionalDefault) == 1 {
return optionalDefault[0]
} else {
return nil
}
}
if len(optionalDefault) == 1 {
return optionalDefault[0]
result := make([]Map, len(slice))
for i := range slice {
result[i] = New(slice[i])
}
return nil
return result
}
// MustObjxMapSlice gets the value as a [](Map).
......
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