ISO8601 DateTime json serialization format changed?

1,674 views
Skip to first unread message

Maxim Mass

unread,
Sep 19, 2012, 2:31:26 PM9/19/12
to servic...@googlegroups.com
We tried updating from ServiceStack 3.5.5.0 to 3.9.9.0 today and noticed a change in the way dates are serialized in json. This is unchanged in both cases:

ServiceStack.Text.JsConfig.DateHandler = ServiceStack.Text.JsonDateHandler.ISO8601;

With ServiceStack 3.5.5.0:
"DateCreated":"\/Date(2012-09-19T03:27:14.0000000)\/"

With ServiceStack 3.9.9.0:
"DateCreated":"2012-09-19T03:27:14.0000000"

Is there a way to revert to the format from 3.5.5.0 to avoid breaking some existing clients? We haven't publicly launched the API yet so if we do introduce a breaking change, now would be the time. Is this new format simpler to work with in JS or other languages and staying unchanged in the foreseeable future in ServiceStack as the ISO8601 format?

Thanks!

Demis Bellot

unread,
Sep 19, 2012, 2:36:18 PM9/19/12
to servic...@googlegroups.com
Which Date did you want? 
The default should be the DataContract serializer default of \/Date(....)\/
Otherwise it's overrideable with JsConfig.DateHandler.

Note: when you want specific behavior to remain (it usually should), submit a test for it - that prevents any changes breaking existing behavior.

Maxim Mass

unread,
Sep 19, 2012, 3:31:46 PM9/19/12
to servic...@googlegroups.com
So sounds like between these two versions of ServiceStack the format for ISO8601 was changed. Perhaps the previous format of  \/Date(2012-09-19T03:27:14.0000000)\/ for ISO8601 was shortlived? It doesn't seem to be supported by the new version of ServiceStack as the new ISO8601 format there is 2012-09-19T03:27:14.0000000 with the default being \/Date(1348050372000-0700)\/. Out of curiosity, do you remember the reasoning for the change?

Personally I prefer the cleaner new ISO8601 format but I'm curious if it's as easy to parse in JS.

Demis Bellot

unread,
Sep 19, 2012, 3:35:30 PM9/19/12
to servic...@googlegroups.com
Note: I didn't add the new DateHandler support, I can't really tell you anything about the change more than the git history logs can.

Modern browsers are going to have native support for parsing ISO8601, for older browsers you can use something like:

Maxim Mass

unread,
Sep 19, 2012, 3:36:55 PM9/19/12
to servic...@googlegroups.com
Fair enough. Thanks for the help.
But yeah it sounds like the format was put in and changed quickly and
we stayed with it for too long. Good that we caught it now before
going live.

Demis Bellot

unread,
Sep 19, 2012, 3:40:38 PM9/19/12
to servic...@googlegroups.com
Which is a good reason to submit your own tests (<- hint ;) to the project to stop any regressions going un-noticed.

Although if the original ISO8601 impl didn't conform to the spec than unfortunately it needs a breaking change to remain compliant.
Reply all
Reply to author
Forward
0 new messages