Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request parsing for null.Time #51

Closed
milosmns opened this issue Nov 10, 2019 · 1 comment
Closed

Request parsing for null.Time #51

milosmns opened this issue Nov 10, 2019 · 1 comment

Comments

@milosmns
Copy link

milosmns commented Nov 10, 2019

I tried this with Gin-Gonic

type AddUserRequest struct {
  // some other properties
  DateOfBirth               null.Time   `json:"user_birthday" time_format:"2006-01-02"`
}

When I send

{
  // some other stuff
  "user_birthday": "2000-04-05"
}

I still get the (infamous?) parsing time \"\"2000-04-05\"\" as \"\"2006-01-02T15:04:05Z07:00\"\": cannot parse \"\"\" as \"T\"" error.

Is there a workaround for this issue? I don't want to send a string and parse manually.

Thanks!

@guregu
Copy link
Owner

guregu commented Apr 25, 2020

Sorry but this library uses this standard library's time.Time JSON marshaler which requires that it be in RFC 3339 format. If you'd like to add support for other formats feel free to fork.

@guregu guregu closed this as completed Apr 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants