Ticket #115 (new enhancement)
Entity.to_dict aims to provide a JSON style structure, but date types are not converted to string
| Reported by: | guest | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | core | Version: | 0.7.1 |
| Keywords: | Cc: |
Description
Hello there,
I'm writing a small application that exposes a JSON API. To make my life easier, I've decided to use the Entity.to_dict' method. But it does not convert datetime objects into string. This breaks, for example, simplejson.dumps' calls.
The problem is that JSON RFC 4627 does not say which format should be used. So, I'd like to suggest to convert dates to the iso8601[0] format that seems to cover almost everything about date representation. It's also good to say that dojo (that javascript library) already uses it as its date format.
In case you think it's a reasonable feature to add to elixir, I think that a simple `strftime' call does the job.
While we don't find a definitive solution I'll extend the Entity class in my app code overriding the to_dict method. but if you're interested, I can provide a patch that changes this directly in elixir.
[0] http://en.wikipedia.org/wiki/ISO_8601
Thanks a lot for this amazing software :)
-- Lincoln de Sousa <lincoln@…>
