This repository has been archived by the owner on Jan 24, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
JavaScriptSerializer not working with TimeSpan #336
Comments
This is a limitation of the Microsoft one too (JSON doesn't really do times/dates), but we can "fix" it by registering a converter:
Then: serializer.RegisterConverters(new[] { new TimeSpanJsonConverter() }); It may be worth discovering / adding a static collection to allow users to add converters, and also ship some (like this one) in the box. |
ghost
assigned grumpydev
Oct 8, 2011
Restructured the JSON namespaces slightly so now the configuration is in the Json namespace (rather than responses) and now has an extra IList property for registering converters which is used in both JsonResponse and the JSON body deserializer. |
grumpydev
added a commit
to grumpydev/Nancy
that referenced
this issue
Oct 8, 2011
Moved JSONSettings to the JSON namespace, added a new converter property and a default TimeSpan converter.
Legend! Thanks :) |
No worries .. it'll be in 0.8.1 this week. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Hi Guys,
Seems to serialise okay:
{"Ticks":12096000000000,"Days":14,"Hours":0,"Milliseconds":0,"Minutes":0,"Seconds":0,"TotalDays":14,"TotalHours":336,"TotalMilliseconds":1209600000,"TotalMinutes":20160,"TotalSeconds":1209600}
But when I deserialize I am getting an empty time span :(
The text was updated successfully, but these errors were encountered: