Uploaded image for project: 'C# Driver'
  1. C# Driver
  2. CSHARP-599

Add option to JsonWriter which allows to output the datetimes in ISO-8601 format



    • Type: New Feature
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Duplicate
    • Affects Version/s: 1.6
    • Fix Version/s: None
    • Component/s: Feature Request
    • Labels:


      Currently the JsonOutputMode-enum offers few different options which allows one to configure how the DateTimes are formatted with JsonWriter. To provide a better compatibility with other frameworks, it would be great if the JsonWriter could be configured to output the dates in ISO-8601 format. This format is currently the default format used by the ASP.NET Web Api: http://www.hanselman.com/blog/OnTheNightmareThatIsJSONDatesPlusJSONNETAndASPNETWebAPI.aspx

      I forked the drivers and added this option in here: https://github.com/mikoskinen/mongo-csharp-driver/commit/a04fe07dd13ac8990b516e4dcdf9d9edd8fb502a

      I added a new boolean UseISO8601DateFormat to JsonWriter which allows you to change the formatting. Is this a good place for it or should there be a new enum option in the JsonOutputMode? Also, I've enable the new formatting only when the flag UseISO8601DateFormat is set to true AND the JsonOutputMode is Shell. I'm not that familiar with the difference of these modes so I'm not sure if this option should be enable for others too.


          Issue Links



              • Votes:
                1 Vote for this issue
                5 Start watching this issue


                • Created: