MarshalJSON marshals the Duration to a string like "30s".
()
| 39 | |
| 40 | // MarshalJSON marshals the Duration to a string like "30s". |
| 41 | func (d Duration) MarshalJSON() ([]byte, error) { |
| 42 | return json.Marshal(d.String()) |
| 43 | } |
| 44 | |
| 45 | func durationFromString(s string) (Duration, error) { |
| 46 | dd, err := time.ParseDuration(s) |