Open smn opened 12 years ago
A related problem is that vumi.message.from_json and .to_json don't correctly roundtrip. Currently
now = datetime.datetime.now() from_json(to_json(now)) != now
The issue is that .to_json encodes all datetime objects as strings but .from_json only converts strings that are values of keys in hashes (i.e. Javascript objects).
To be more precise, we should probably standardize on something like RFC 3339, which is a subset / profile of ISO 8601 intended for Internet protocols. Atom uses it, among others.
(The reason for a subset like RFC 3339 is that full ISO 8601 actually includes a number of format variations which are not really desirable for Internet use, such ordinal weeks and days.)
@hodgestar: With json.JSONDecoder
, at least, the only way to do it seems to be to recurse from within our object_hook
. There's one example of doing that here.
Alternatively, we could investigate a more flexible third-party JSON library?
@piet-praekelt My plan was not to allow any keys to be datetime.datetime objects (i.e. don't support them in the JSON encoder) but have a convenience method for accessing timestamp values as datetime objects if needed.
@hodgestar: Ah, that sounds good.
Not our own funny format. Allow for the old version to remain working but deprecated for 0.4 with 0.5 removing it completely.