@@ -39,7 +39,12 @@ func encodeMapStringBoolValue(e *Encoder, v reflect.Value) error {
3939 return err
4040 }
4141
42- m := v .Convert (mapStringBoolType ).Interface ().(map [string ]bool )
42+ var m map [string ]bool
43+ if v .Type () == mapStringBoolType {
44+ m = v .Interface ().(map [string ]bool )
45+ } else {
46+ m = v .Convert (mapStringBoolType ).Interface ().(map [string ]bool )
47+ }
4348 if e .flags & sortMapKeysFlag != 0 {
4449 return e .encodeSortedMapStringBool (m )
4550 }
@@ -65,7 +70,12 @@ func encodeMapStringStringValue(e *Encoder, v reflect.Value) error {
6570 return err
6671 }
6772
68- m := v .Convert (mapStringStringType ).Interface ().(map [string ]string )
73+ var m map [string ]string
74+ if v .Type () == mapStringStringType {
75+ m = v .Interface ().(map [string ]string )
76+ } else {
77+ m = v .Convert (mapStringStringType ).Interface ().(map [string ]string )
78+ }
6979 if e .flags & sortMapKeysFlag != 0 {
7080 return e .encodeSortedMapStringString (m )
7181 }
@@ -86,7 +96,12 @@ func encodeMapStringInterfaceValue(e *Encoder, v reflect.Value) error {
8696 if v .IsNil () {
8797 return e .EncodeNil ()
8898 }
89- m := v .Convert (mapStringInterfaceType ).Interface ().(map [string ]interface {})
99+ var m map [string ]interface {}
100+ if v .Type () == mapStringInterfaceType {
101+ m = v .Interface ().(map [string ]interface {})
102+ } else {
103+ m = v .Convert (mapStringInterfaceType ).Interface ().(map [string ]interface {})
104+ }
90105 if e .flags & sortMapKeysFlag != 0 {
91106 return e .EncodeMapSorted (m )
92107 }
0 commit comments