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
Adding these methods to time.Duration would make it easier to write and read JSON data containing time.Duration objects. In Go 1.7 it will be possible to use maps in which the keys implement the two methods for marshalling and unmarshalling JSON.
Like time.Time the amount of code added should be minimal, as time.ParseDuration and time.Duration.String are already in place.
Some projects already wrap the time.Duration type to get this behavior:
The text was updated successfully, but these errors were encountered:
bystones
changed the title
proposal: add MarshalJSON/UnmarshalJSON and MarshalText/UnmarshalText to time.Duration
proposal: add MarshalText/UnmarshalText to time.Duration
Jun 11, 2016
Sorry, I think we're going to reject this on the grounds that the JSON spec does not define a way to stringify time durations. It also adds too much complexity and awareness of JSON to the low-level time package.
Adding these methods to time.Duration would make it easier to write and read JSON data containing time.Duration objects. In Go 1.7 it will be possible to use maps in which the keys implement the two methods for marshalling and unmarshalling JSON.
Like time.Time the amount of code added should be minimal, as time.ParseDuration and time.Duration.String are already in place.
Some projects already wrap the time.Duration type to get this behavior:
The text was updated successfully, but these errors were encountered: