views:

36

answers:

2

I'm trying to deserialize/serialize a timespan,

but when the json is send it's set to 00:00:00 is this even possible to do?

Thanks! -Kevin

Btw, Language is C#, using Visual Studio 2008.

A: 
http://msdn.microsoft.com/en-us/library/bb412179.aspx

The JSON serializer throws a serialization exception for data contracts that have multiple members with the same name, as shown in the following sample code.

Copy

[DataContract]
public class TestDuplicateDataBase
{
    [DataMember]
    public int field1 = 123;
}
[DataContract]
public class TestDuplicateDataDerived : TestDuplicateDataBase
{
    [DataMember]
    public new int field1 = 999;
}
Joe Garrett
A: 

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. http://forums.silverlight.net/forums/p/51793/135450.aspx

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);

Kevin