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
The behavior of JSON marshaling when the MarshalText method is used isn't well-specified:
If no MarshalJSON method is present but the value implements encoding.TextMarshaler instead, Marshal calls its MarshalText method. The nil pointer exception is not strictly necessary but mimics a similar, necessary exception in the behavior of UnmarshalJSON.
Note that it says that MarshalJSON is called "to produce JSON", but there's nothing indicating that MarshalText produces a JSON string (i.e., the value is escaped as a string and surrounding quotes are added).
Compare with the docs about UnmarshalText (docs added in 1.8):
Otherwise, if the value implements encoding.TextUnmarshaler and the input is a JSON quoted string, Unmarshal calls that value's UnmarshalText method with the unquoted form of the string.
I can send a CL later.
The text was updated successfully, but these errors were encountered: