1
0
mirror of https://github.com/json-iterator/go.git synced 2025-03-29 21:20:52 +02:00

#35 fix json.Number matches string

This commit is contained in:
Tao Wen 2017-06-02 15:43:58 +08:00
parent 4cc44e7380
commit a7f992f0e1

View File

@ -337,10 +337,10 @@ func decoderOfType(typ reflect.Type) (Decoder, error) {
}
func createDecoderOfType(typ reflect.Type) (Decoder, error) {
if typ.ConvertibleTo(jsonRawMessageType) {
if typ.AssignableTo(jsonRawMessageType) {
return &jsonRawMessageCodec{}, nil
}
if typ.ConvertibleTo(jsonNumberType) {
if typ.AssignableTo(jsonNumberType) {
return &jsonNumberCodec{}, nil
}
if typ.ConvertibleTo(unmarshalerType) {
@ -424,10 +424,10 @@ func encoderOfType(typ reflect.Type) (Encoder, error) {
}
func createEncoderOfType(typ reflect.Type) (Encoder, error) {
if typ.ConvertibleTo(jsonRawMessageType) {
if typ.AssignableTo(jsonRawMessageType) {
return &jsonRawMessageCodec{}, nil
}
if typ.ConvertibleTo(jsonNumberType) {
if typ.AssignableTo(jsonNumberType) {
return &jsonNumberCodec{}, nil
}
if typ.ConvertibleTo(marshalerType) {