Skip to content

Commit

Permalink
Specify explicit json serializer settings
Browse files Browse the repository at this point in the history
  • Loading branch information
pieceofsummer committed Aug 10, 2018
1 parent 3a11603 commit 3075133
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/Hangfire.Console/Dashboard/JobProgressDispatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using Hangfire.Dashboard;
using Hangfire.States;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;

namespace Hangfire.Console.Dashboard
{
Expand All @@ -16,6 +17,14 @@ namespace Hangfire.Console.Dashboard
/// </summary>
internal class JobProgressDispatcher : IDashboardDispatcher
{
private static readonly JsonSerializerSettings JsonSettings = new JsonSerializerSettings()
{
ContractResolver = new CamelCasePropertyNamesContractResolver()
{
NamingStrategy = new CamelCaseNamingStrategy(false, true)
}
};

// ReSharper disable once NotAccessedField.Local
private readonly ConsoleOptions _options;

Expand Down Expand Up @@ -62,7 +71,7 @@ public async Task Dispatch(DashboardContext context)
}
}

var serialized = JsonConvert.SerializeObject(result);
var serialized = JsonConvert.SerializeObject(result, JsonSettings);

context.Response.ContentType = "application/json";
await context.Response.WriteAsync(serialized);
Expand Down

0 comments on commit 3075133

Please sign in to comment.