facebook-csharp-sdk / simple-json

JSON library for .NET 2.0+/SL4+/WP7/WindowsStore with optional support for dynamic and DataContract
MIT License
380 stars 143 forks source link

Support for TimeSpan #60

Closed fiacc closed 7 years ago

fiacc commented 10 years ago

Currently when a TimeSpan is being Serialized it's being treated as an unknown type and ends up in TrySerializeUnknownTypes where it's reflected on and serialized as

{
    "Ticks":10040000000,
    "Days":0,
    "Hours":0,
    "Milliseconds":0,
    "Minutes":16,
    "Seconds":44,
    "TotalDays":0.011620370370370369,
    "TotalHours":0.27888888888888885,
    "TotalMilliseconds":1004000,
    "TotalMinutes":16.733333333333334,
    "TotalSeconds":1004
  }

I added explicit checks for TimeSpan. Not 100% sure what the TimeSpan Format strings should be so I stuck with the defaults.