martini-contrib / binding

Martini handler for mapping and validating a raw request into a structure.
MIT License
140 stars 47 forks source link

Error when binding structs with dates #39

Open javiermanzano opened 9 years ago

javiermanzano commented 9 years ago

I've just had a problem while trying to bind a struct with some dates on it like this

{"birthDate":"2015-02-19T00:00:00", "name": "name", "place": "Málaga"}

It evens doesn't show me any error... It just doesn't bind any data.

Anyone on this?

mholt commented 9 years ago

What does your struct definition look like?

javiermanzano commented 9 years ago

The problem was that date was missing "Z" at the end. A correct JSON would be:

{"birthDate":"2015-02-19T00:00:00", "name": "name", "place": "Málaga"}

It's because the use of the encoding/json package. Shouldn't it throw any error instead of returning me an instance that does not contain anything?

mholt commented 9 years ago

I'm not sure... that might have more to do with the encoding/json package. I've been super-busy the last few weeks; have you taken the chance to peruse the source and see how it handles time.Time fields?