1
0
mirror of https://github.com/json-iterator/go.git synced 2025-07-09 23:45:32 +02:00

Fix custom marshaler for enum types

When MarshalJSON was defined on a pointer receiver custom enum type
marshaling/unmarshaling was panicing since the underlying primitive type
was treated as a pointer.

Since method set for pointer receivers includes value receiver methods
we don't really need optionalEncoder and can just use marshalEncoder
directly.
This commit is contained in:
Oleg Shaldybin
2017-09-14 23:04:54 -07:00
parent eef35e549b
commit ae57d167e8
3 changed files with 51 additions and 1 deletions

View File

@ -476,7 +476,6 @@ func createEncoderOfType(cfg *frozenConfig, typ reflect.Type) (ValEncoder, error
templateInterface: extractInterface(templateInterface),
checkIsEmpty: checkIsEmpty,
}
encoder = &optionalEncoder{encoder}
return encoder, nil
}
if typ.Implements(textMarshalerType) {