Skip to content

marshaling byte slice ignores json.Marshaler/encoding.TextMarshaler interfaces #16

Closed
@wI2L

Description

@wI2L

When a codec is created for a byte-slice type at

case bytesType:

it ignores the fact that the type could be implementing the json.Marshaler or encoding.TextMarshaler interfaces. This should be considered in priority, to be compliant with the standard library.

The following playground demonstrates the issue:
https://play.golang.org/p/Bm0d3jsWkZf

The relevant code can be found in the standard library at https://github.com/golang/go/blob/da4d58587e0e4028ea384580053c3c455127e446/src/encoding/json/encode.go#L415
The function newTypeEncoder checks in priority if the reflect.Value implements one of the interfaces.

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions