Skip to content

Commit

Permalink
Force string-typed keys
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Jordan Olshevski authored and ashald committed May 25, 2019
1 parent 6f1a40a commit 20b2b74
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion decode.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{})
Expand Down

0 comments on commit 20b2b74

Please sign in to comment.