From 20b2b746569ef4887b26436659abdc8b264c0dea 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 e4e56e28..973dea7b 100644 --- a/decode.go +++ b/decode.go @@ -234,7 +234,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() timeType = reflect.TypeOf(time.Time{}) ptrTimeType = reflect.TypeOf(&time.Time{})