I am using to json.NewDecoder.Decode to get data from http.response like following
if response.StatusCode == http.StatusOK {
var httpResponse models.httpResponse
err = json.NewDecoder(response.Body).Decode(&httpResponse)
if err != nil {
logger.Info(err.Error())
}
....
}
type httpResponse struct {
SomeField1 string `json:"somefield1"`
SomeField2 string `json:"somefield2"`
Timestamp1 time.Time `json:"Timestamp1"`
Timestamp2 time.Time `json:"Timestamp2"`
}
I noticed that one of the timeStamp Timestamp1 with value("2013-06-25T18:09:22.123321Z") in the response was converted to
0001-01-01 00:00:00 +0000 UTC
. But another timeStamp Timestamp2 with value("2014-03-26T03:59:59.999Z") has the right value after the Decode.
I've also tried json.Unmarshal, same results. Please advise.