binding icon indicating copy to clipboard operation
binding copied to clipboard

Error when binding structs with dates

Open javiermanzano opened this issue 10 years ago • 3 comments

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?

javiermanzano avatar Feb 18 '15 16:02 javiermanzano

What does your struct definition look like?

mholt avatar Feb 18 '15 16:02 mholt

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?

javiermanzano avatar Feb 19 '15 14:02 javiermanzano

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?

mholt avatar Feb 25 '15 16:02 mholt