From fed405d3ff0196902158fa42d4b938cd327089a6 Mon Sep 17 00:00:00 2001 From: Andrey Date: Mon, 24 Aug 2015 15:01:28 +0600 Subject: [PATCH] Fix ObjxMapSlice --- type_specific_codegen.go | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/type_specific_codegen.go b/type_specific_codegen.go index f3ecb29..95b2241 100644 --- a/type_specific_codegen.go +++ b/type_specific_codegen.go @@ -315,13 +315,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).