-
Notifications
You must be signed in to change notification settings - Fork 18.8k
Closed
Labels
FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.The path to resolution is known, but the work has not been done.
Milestone
Description
The following demonstrates the problem:
---------------
package main
import (
"encoding/json"
"fmt"
"bytes"
"time"
)
type RegisterStructure struct {
SignupTimestamp time.Time `json:"signuptimestamp,omitempty"`
}
func main() {
requestBody := []byte(`{"signuptimestamp" : null}`)
dec := json.NewDecoder(bytes.NewReader(requestBody))
registerInstance := RegisterStructure{}
err := dec.Decode(®isterInstance)
if err != nil {
fmt.Println(err)
}
}
---------------
This reports the following error:
----------------------------
parsing time "null" as ""2006-01-02T15:04:05Z07:00"":
cannot parse "null" as """
----------------------------
Instead, what should probably happen is to set to the time.Time zero value. This came
up in the course of answering on Stack Overflow:
http://stackoverflow.com/questions/26684752/json-decode-cannot-parse-timestamp-in-json-into-go-structMarkSRobinson, sgykfjsm, zignd and somprabhsharma
Metadata
Metadata
Assignees
Labels
FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.The path to resolution is known, but the work has not been done.