Open
Description
Assuming jsoniter
is supposed to be 100% compatible with encoding/json
, it appears that jsoniter does not serialize map keys of custom types correctly, in that it does not use the MarshalText
method when provided.
The standard behavior is that any type implementing the TextMarshaler
interface should use MarshalText
when marshaling itself.
The strange thing is that this incorrect behavior only happens when the map key is a value. When the map key is a pointer, it's fine.
To illustrate what I mean, consider these four scenarios:
- using encoding/json - key is pointer
- using encoding/json - key is value
- using jsoniter - key is pointer
- using jsoniter - key is value
You'll notice that the first three scenarios is able to pick up on the custom behavior added by MarshalText
, but the fourth one does not.
Metadata
Metadata
Assignees
Labels
No labels