You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In trying to move from v4 to v5, I noticed that v5 checks for the implementation of encoding.TextMarshaler, and if present, encodes its output as bytes.
Since encoding.TextMarshaler is intended to provide a textual, UTF-8 representation of an object, it often does not include the necessary information to fully round-trip all fields.
Expected Behavior
Using a type such as String found here or in the many similar packages used for working with relational databases, a msgpack.Marshal()msgpack.Unmarshal() sequence should result in equivalent values for all struct fields.
Current Behavior
None of the original information is preserved; an error like this is returned:
msgpack: invalid code=c4 decoding map length
Possible Solution
Removing the check for the implementation of encoding.TextMarshaler would be a breaking change in v5, and in other use cases it may very well be valuable; in fact, it must have been added for this reason. But it would be nice to be able to configure a msgpack decoder with an option not to check for the encoding.TextMarshaler implementation, since by its definition in the encoding package, TextMarshaler will often produce output that does not fully encode the object.
Since v4 didn't do this, and types that implement TextMarshaler are in widespread use throughout my code base, it appears that an easy migration to v5 is not possible
Detailed Description
I'd like a way to opt out of using TextMarshaler and TextUnmarshaler.
Possible Implementation
The text was updated successfully, but these errors were encountered:
In trying to move from v4 to v5, I noticed that v5 checks for the implementation of
encoding.TextMarshaler
, and if present, encodes its output as bytes.Since
encoding.TextMarshaler
is intended to provide a textual, UTF-8 representation of an object, it often does not include the necessary information to fully round-trip all fields.Expected Behavior
Using a type such as
String
found here or in the many similar packages used for working with relational databases, amsgpack.Marshal()
msgpack.Unmarshal()
sequence should result in equivalent values for all struct fields.Current Behavior
None of the original information is preserved; an error like this is returned:
Possible Solution
Removing the check for the implementation of encoding.TextMarshaler would be a breaking change in v5, and in other use cases it may very well be valuable; in fact, it must have been added for this reason. But it would be nice to be able to configure a msgpack decoder with an option not to check for the
encoding.TextMarshaler
implementation, since by its definition in the encoding package,TextMarshaler
will often produce output that does not fully encode the object.Steps to Reproduce
Context (Environment)
Since v4 didn't do this, and types that implement TextMarshaler are in widespread use throughout my code base, it appears that an easy migration to v5 is not possible
Detailed Description
I'd like a way to opt out of using TextMarshaler and TextUnmarshaler.
Possible Implementation
The text was updated successfully, but these errors were encountered: