Bug 16070 - DataContractJsonSerializer gives different results from Windows when serializing a TimeSpan
Summary: DataContractJsonSerializer gives different results from Windows when serializ...
Alias: None
Product: Android
Classification: Xamarin
Component: BCL Class Libraries ()
Version: 4.6.x
Hardware: PC Windows
: Normal normal
Target Milestone: ---
Assignee: Martin Baulig
Depends on:
Reported: 2013-11-08 19:31 UTC by Jon Goldberger [MSFT]
Modified: 2016-11-11 09:52 UTC (History)
2 users (show)

Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Comment 1 Jon Goldberger [MSFT] 2013-11-08 19:33:54 UTC
I have an existing Windows Phone and Windows Store App which talk to a web service. All 3 are using DataContractJsonSerializer.

Now I'm porting my WP App to Android and run into an issue with the Android version of DataContractJsonSerializer.

On Windows a TimeSpan is serialized in ISO 8601<http://en.wikipedia.org/wiki/ISO_8601#Time_intervals>; format, e.g. "PT0S".

On Android it is serialized as a _ticks object, e.g. {"_ticks":0}

Is this a known issue? Any simple workaround possible? I don't want to move to another JSON package if possible.
attached are two sample projects:

DataContractJsonSerializerWin is a Windows Console App and shows the result of the Json serialization of an object with TimeSpan property.

DataContractJsonSerializerProblem is an Android project and shows the different output created by Xamarin. This different output creates my troubles!

Expected (Windows):

Result (Xamarin):

This data is send to a windows based web service which can NOT deserialize the Xamarin output.
Comment 3 Martin Baulig 2016-11-11 09:52:10 UTC
Closing ancient bugs, please reopen if you're still having this problem.