JSON Serialization in Web Api 2 not using ISO 8601 dates

Viewed 16472

I'm using WebApi 2 to send some Json down to the client and its using the old style Date serialization and not ISO 8601.

I'm seeing:

"current_period_start": "\/Date(1388153705)\/",
"current_period_end": "\/Date(1390832105)\/",
"start": "\/Date(1388332525)\/",

My Global.asax.cs looks like this:

        GlobalConfiguration.Configure(WebApiConfig.Register);
        var formatters = GlobalConfiguration.Configuration.Formatters;
        var jsonFormatter = formatters.JsonFormatter;
        var settings = jsonFormatter.SerializerSettings;
        settings.Converters.Add(new IsoDateTimeConverter());
        settings.Formatting = Formatting.Indented;
        settings.ContractResolver = new CamelCasePropertyNamesContractResolver();
2 Answers
Related