// UnmarshalJSON implements the encoding/json Unmarshaler interface. It will
// decode a given []byte into t so long as the provided []byte
// is a valid JSON representation of an ISO 8601 string. Empty strings and
// the 'null' keyword will both decode into a null NullTime.
//
// If the decode fails, the value of t will be unchanged.
UnmarshalJSON implements the encoding/json Unmarshaler interface. It will
decode a given []byte into t so long as the provided []byte
is a valid JSON representation of an ISO 8601 string. Empty strings and
the 'null' keyword will both decode into a null NullTime.

If the decode fails, the value of t will be unchanged.
// UnmarshalJSON implements the encoding / json Unmarshaler interface . It will // decode a given [] byte into t so long as the provided [] byte // is a valid JSON representation of an ISO 8601 string . Empty strings and // the ' null ' keyword will both decode into a null NullTime . // // If the decode fails the value of t will be unchanged .
func (t *Time) UnmarshalJSON(data []byte) error {
	if t == nil {
		return fmt.Errorf("null.Time: UnmarshalJSON called on nil pointer")
	}
	var j interface{}
	if err := json.Unmarshal(data, &j); err != nil {
		return err
	}
	switch val := j.(type) {
	case string:
		if len(val) == 0 {
			t.Time = time.Time{}
			t.Valid = false
			return nil
		}
		tmp, err := iso8601.Parse([]byte(val))
		if err != nil {
			return err
		}
		t.Time = tmp
		t.Valid = true
		return nil
	case nil:
		t.Time = time.Time{}
		t.Valid = false
		return nil
	default:
		return fmt.Errorf("null.Time: cannot unmarshal JSON of type %T (%v)",
			val, data)
	}
}
func ( t * Time ) UnmarshalJSON ( data [ ] byte ) error { if t == nil { return fmt . Errorf ( " " ) } var j interface { } if err := json . Unmarshal ( data , & j ) ; err != nil { return err } switch val := j . ( type ) { case string : if len ( val ) == 0 { t . Time = time . Time { } t . Valid = false return nil } tmp , err := iso8601 . Parse ( [ ] byte ( val ) ) if err != nil { return err } t . Time = tmp t . Valid = true return nil case nil : t . Time = time . Time { } t . Valid = false return nil default : return fmt . Errorf ( " " , val , data ) } }
UnmarshalJSON implements the encoding/json Unmarshaler interface.
UnmarshalJSON implements the encoding / json Unmarshaler interface .
// TODO: If time.Time.UnmarshalJSON doesn't change the value of the // receiver we could skip the temporary object by calling .UnmarshalJSON // on t.Time.