Json Date Serializer
So, you are introducing a BREAKING CHANGE with this. Just GREAT!!!I know you may hate the existing datetime format (I do to), but existing sites really rely on that, and this artical on MSDN.Basically, I can't just update to use this instead of the existing api for a few reasons:1) Breaking the contract - We have told our users that the date has to be in this format2) We have a strict restriction on using 3rd party libraries, so now you are DEFAULTING to it?? Our legal department will have a fit!3) This also means you won't be using the DataContractJsonSeralizer anymore? What about WCF? Is it also switching, or do we have issues within our own app (WCF expecting one format, and this giving another).PLEASE DO NOT set JSON.NET as the default, but make it available, and fix the DataContractJsonSerializer to support more date formats than the /Date(xxx)/ one. My concern is the same.
If I just upgrade, without making any code changes, it will change the format. This release was SUPPOSED to be an inline update that DID NOT have any breaking changes - THIS IS ONE.And then, what about, like us, a large corp that can't update everything at once, we have some using the old and some using the new format.This means, even if we could get by our legal department (they look really hard at the license agreement) that we can NEVER use the new format, as it won't work with the systems that still require the old, unless they update DataContractJsonSerializer with support for more dates.
Chad - You don't use modernizr, Jquery, jqueryUI or any of the other 3rd party libs? This will be supported Open Source just like our existing uses I open source. Want to use a different default?
JavaScript doesn't have a date literal, and for this reason JSON serializes dates as strings rather than real JavaScript dates. In this post I show how JSON date serialization works, a few approaches how you can manage dates and how to automate the process of converting JSON dates to 'real' dates more. Mar 30, 2017. The dateTime member represents the instance in time when the event of interest occurred (again, it becomes a DateTime in JavaScript when ASP.NET AJAX is in use and a string when it is not). On serialization, the dateTime member is always serialized in GMT. So, if describing 3:00 AM New York time,. The quickest method of converting between JSON text and a.NET object is using the T:Newtonsoft.Json.JsonSerializer. The JsonSerializer converts.NET objects into their JSON equivalent and back again by mapping the.
Easy to switch back. Remember that when we include open source, we back it with support.
If you call and have a problem with ASP.NET, we will support all of it, including the open source we ship. Does that help? We have been doing that for 3+ years now.Also, Chad - we are changing only ASP.NET Web API.A product that isn't released. We aren't changing asp.net proper or WCF. There is no breaking change as this is a new product, only now in beta. OK, so now only the webapi is updated, that is better, but we still won't be able to use it.I was more making a point about the library (as we already use JSON.NET in some situations.The problem I see now is one of incompatibility.
If you aren't updating WCF, or ASP.NET, dates creating in one won't work in the other. So how do you suggest calling an existing service when you have a DateTime as a property in the serialized object?
How do you know what format to put it in?I know that JSON.NET can handle it, but it requires a special date handler, and DataContractJsonSerializer won't handle the new format. Can there at least be updates to make it EASILY work between services, without having to know what date format it is in.DateTime.Parse handles several, but not the existing DataContractJsonSerailizer format, and then there is JavascriptSerializer - which is different.I really like the simplicity of the DataContractJsonSerializer, and have heard several of my coworkers complain about JSON.NET. Please what ever you do, don't base it off Microsoft's broken format for IS8601. Make sure that it comes out with millisecond resolution and nothing more, that the time zone is always included.
Json Deserialize Python
In cases of DateTime please use local machine timezone or UTC timezone of 'Z'.This is how dates should be formatted from DateTime and DateTimeOffset.' Fff'Z'I can't tell you how much it pains me to see all these different so called ISO formats in the.NET framework that don't really reflect reality.
To clarify my comment from above, the only DateTime formatter that follows ISO 8601 is 'o'. But the industry as a whole, as pretty much settled on millisecond resolution for the DateTime format, mostly because this is the resolution of UNIX time.It would be great if Microsoft also supported this.yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'
Fffffffzzz (this is the 'o' format, which is ISO 8601)yyyy'-'MM'-'dd'T'HH':'mm':'ss'.' Fff'Z' (this is the industry standard ISO 8601 format)It would save me a lot of time trying to create the most usable API across web clients, if Microsoft out of the box just supported this second format.Thanks. Yes, dates are really hard. The worst part is that most developers think that because its in the BCL that DateTime is perfect.
There are a few guys trying to do something about it, by re-implementing java's 'joda' project as pure.net. Check out Jon Skeet's post about 'Noda Time' DataContractJsonSerializer is pretty bad with JSON Dates.
It completely ignores the offset when deserializing, among other things. Super glad to head about JSON.Net being used for webapi instead. Question - is System.Json a different serializer than DCJS (in System.Runtime.Serialization) If not, why the new namespace? The first thing I was going to do with the Web API is make it play with JSON.NET now I don't have to:) Web API using JSON.NET by default is awesome news thank you.@Rob I also needed more control over JSON formatting, before I knew about Web API I created a JsonValueProviderFactory using JSON.NET. If you use my JsonValueProviderFactory and create a ActionResult that returns JsonConvert.SerializeObject(myModel); you will have completely swapped out the JavaScriptSerializer from MVC.http://www.dalsoft.co.uk/blog/index.php/2012/01/10/asp-net-mvc-3-improved-jsonvalueproviderfactory-using-json-net/.
Scott,One more pet peeve. Entity Framework returns DateTimes back as DateTimeKind.Unspecified. I save all of my DateTimes to the DB in UTC, but if the JSON serializer sees DateTimeKind.Unspecified, it figures it is local time and again, converts to UTC for a JSON Date(xxxxx) response. The result is double hour shifting!I wrote a T4 template that forces all retrieved DateTime objects from the DB to come back as DateTimeKind.UTC by default, but a simple config file flag to force EF to return them UTC, built in, would be A-W-E-S-O-M-E.My blog post on this: http://www.aaroncoleman.net/post/2011/06/16/Forcing-Entity-Framework-to-mark-DateTime-fields-at-UTC.aspx-Aaron.