Let's code

json: unmarshal custom date formats

When we are building a JSON API, many times we have to deal with dates that we can’t have control of the layout. Let’s see a common example using a format that Go knows by default. type Checkin struct { Timestamp time.Time `json:"timestamp"` User string `json:"user"` } func main() { j := `{"timestamp":"2016-11-02T08:18:20Z", "user":"John Doe"}` var c Checkin // error handling omitted for simplicity (don't do this). json.Unmarshal([]byte(j), &c) fmt.Println(c) } Run on Playground.