diff --git a/AS1024.GeoFeed/AS1024.GeoFeed.csproj b/AS1024.GeoFeed/AS1024.GeoFeed.csproj index 3d04b4f..18bbe69 100644 --- a/AS1024.GeoFeed/AS1024.GeoFeed.csproj +++ b/AS1024.GeoFeed/AS1024.GeoFeed.csproj @@ -10,7 +10,6 @@ - diff --git a/AS1024.GeoFeed/GeoFeedBuilder/NetBoxGeoFeedProvider.cs b/AS1024.GeoFeed/GeoFeedBuilder/NetBoxGeoFeedProvider.cs index c5ab21a..7f2aecc 100644 --- a/AS1024.GeoFeed/GeoFeedBuilder/NetBoxGeoFeedProvider.cs +++ b/AS1024.GeoFeed/GeoFeedBuilder/NetBoxGeoFeedProvider.cs @@ -1,6 +1,6 @@ using AS1024.GeoFeed.Interfaces; using AS1024.GeoFeed.Models; -using Newtonsoft.Json; +using System.Text.Json; using System.Net.Http.Headers; using System.Net.Sockets; using System.Web; @@ -49,7 +49,9 @@ namespace AS1024.GeoFeed.GeoFeedBuilder if (result.IsSuccessStatusCode) { string stringResult = await result.Content.ReadAsStringAsync(); - jsonData = JsonConvert.DeserializeObject(stringResult); + jsonData = JsonSerializer.Deserialize(stringResult, new JsonSerializerOptions { + PropertyNamingPolicy = JsonNamingPolicy.SnakeCaseLower + }); if (jsonData?.Results == null || jsonData.Results.Count == 0) { diff --git a/AS1024.GeoFeed/Models/GeoFeed.cs b/AS1024.GeoFeed/Models/GeoFeed.cs index 5233f59..45bbfec 100644 --- a/AS1024.GeoFeed/Models/GeoFeed.cs +++ b/AS1024.GeoFeed/Models/GeoFeed.cs @@ -1,5 +1,4 @@ -using Newtonsoft.Json; - +using System.Text.Json.Serialization; namespace AS1024.GeoFeed.Models { public class NetboxData @@ -12,21 +11,15 @@ namespace AS1024.GeoFeed.Models public class Result { public string? Prefix { get; set; } - [JsonProperty("custom_fields")] public CustomFields? CustomFields { get; set; } } public class CustomFields { - [JsonProperty("geoloc_city")] public string? GeolocCity { get; set; } - [JsonProperty("geoloc_country")] public string? GeolocCountry { get; set; } - [JsonProperty("geoloc_has_location")] public bool? GeolocHasLocation { get; set; } - [JsonProperty("geoloc_region")] public string? GeolocRegion { get; set; } - [JsonProperty("geoloc_postal_code")] public string? GeolocPostalCode { get; set; } }