Skip to content
This repository was archived by the owner on Jul 31, 2025. It is now read-only.
This repository was archived by the owner on Jul 31, 2025. It is now read-only.

Cannot json.Unmarshall dynamodbstream.StreamRecord because of unix time set in field #796

@xoraes

Description

@xoraes

The dynamodbstream.StreamRecord struct has a time.Time field:
//ApproximateCreationDateTime *time.Time type:"timestamp" timestampFormat:"unix".

Its not convenient to json.Unmarshal unix Time in Go without writing a custom type for time. I am trying to use this struct to unmarshal stream records from dynamo, but that fails because json.Unmarshal cannot parse unix time by default. I get this error:

{"error":"parsing time "1470788940" as ""2006-01-02T15:04:05Z07:00"": cannot parse "1470788940" as """"}

Can we wrap the time fields into a struct and provide a marshaller and unmarshaller for parsing unix time ? something like this perhaps:

type UnixTime struct {
time.Time
}

func (t *UnixTime) UnmarshalJSON(buf []byte) error
func (t *UnixTime) MarshalJSON(buf []byte) error

Without this I have to maintain a copy of this struct in my code, which is bad in many ways.

Metadata

Metadata

Assignees

Labels

feature-requestA feature should be added or improved.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions