From 85482c8b225b4cb87bcb8532d2bf81b72b2f4c3c Mon Sep 17 00:00:00 2001 From: Jordan Olshevski Date: Wed, 13 Jul 2016 09:34:24 -0700 Subject: [PATCH] Force string-typed keys When unmarshaling objects to map[string]interface{}, map values will be of the type map[interface{}]interface{}. This is problematic when attempting to marshal the object out to JSON, since encoding/json only supports string keys. This change is a patch to cause all child maps to have string-typed keys. --- decode.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/decode.go b/decode.go index 085cddc4..c5630237 100644 --- a/decode.go +++ b/decode.go @@ -196,7 +196,7 @@ type decoder struct { var ( mapItemType = reflect.TypeOf(MapItem{}) durationType = reflect.TypeOf(time.Duration(0)) - defaultMapType = reflect.TypeOf(map[interface{}]interface{}{}) + defaultMapType = reflect.TypeOf(map[string]interface{}{}) ifaceType = defaultMapType.Elem() )