c# json web-services

Using JSON to Serialize/Deserialize TimeSpan

I’m trying to deserialize/serialize a timespan with Newtonsoft.Json.JsonConvert, but when the JSON is sent it’s set to 00:00:00.

Is this even possible to do?

I figured it out, Apparently it’s a MS design flaw…

Since TimeSpan cannot be a parameterless object. XML cannot recreate it.

Take a look at this website.

So. Therefore TimeSpan cannot be converted. An easy way to do this is
to change the timespan into a string, and then send the string over.
and use TimeSpan.TryParse(String);