diff --git a/Weather/Service/Models/WeatherAggregate.cs b/Weather/Service/Models/WeatherAggregate.cs index d4afe3f..4298862 100644 --- a/Weather/Service/Models/WeatherAggregate.cs +++ b/Weather/Service/Models/WeatherAggregate.cs @@ -3,8 +3,6 @@ using System.Collections.Generic; using System.Linq; using ChrisKaczor.HomeMonitor.Weather.Models; using JetBrains.Annotations; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; namespace ChrisKaczor.HomeMonitor.Weather.Service.Models { @@ -21,7 +19,6 @@ namespace ChrisKaczor.HomeMonitor.Weather.Service.Models public ReadingAggregate WindSpeed { get; set; } - [JsonConverter(typeof(StringEnumConverter))] public WindDirection WindDirectionAverage { get; set; } public decimal RainTotal { get; set; } diff --git a/Weather/Service/Startup.cs b/Weather/Service/Startup.cs index c2b6b95..96a190a 100644 --- a/Weather/Service/Startup.cs +++ b/Weather/Service/Startup.cs @@ -6,6 +6,7 @@ using Microsoft.AspNetCore.ResponseCompression; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using System.IO.Compression; +using System.Text.Json.Serialization; namespace ChrisKaczor.HomeMonitor.Weather.Service { @@ -27,7 +28,10 @@ namespace ChrisKaczor.HomeMonitor.Weather.Service services.AddCors(o => o.AddPolicy("CorsPolicy", builder => builder.AllowAnyMethod().AllowAnyHeader().AllowCredentials().WithOrigins("http://localhost:4200"))); - services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_3_0); + services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_3_0).AddJsonOptions(configure => + { + configure.JsonSerializerOptions.Converters.Add(new JsonStringEnumConverter()); + }); } public void Configure(IApplicationBuilder applicationBuilder, IWebHostEnvironment environment)