diff --git a/src/AtleX.HaveIBeenPwned/HaveIBeenPwnedClient.cs b/src/AtleX.HaveIBeenPwned/HaveIBeenPwnedClient.cs index b3f59f5..fa8c10c 100644 --- a/src/AtleX.HaveIBeenPwned/HaveIBeenPwnedClient.cs +++ b/src/AtleX.HaveIBeenPwned/HaveIBeenPwnedClient.cs @@ -1,4 +1,5 @@ using AtleX.HaveIBeenPwned.Helpers; +using AtleX.HaveIBeenPwned.Serialization.Json; using Pitcher; using SwissArmyKnife; using System; @@ -43,6 +44,11 @@ public sealed class HaveIBeenPwnedClient /// private readonly bool _enableClientDisposing; + /// + /// Gets the to use when (de)serializing JSON + /// + private static readonly JsonSerializerOptions JsonOptions = JsonSerializerOptionsFactory.Create(); + /// /// Initializes a new instance of with the /// specified and @@ -337,7 +343,7 @@ private async Task GetAsync(HttpRequestMessage requestMessage, Cancellatio using var content = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); var result = await JsonSerializer - .DeserializeAsync(content, cancellationToken: cancellationToken) + .DeserializeAsync(content, options: JsonOptions, cancellationToken: cancellationToken) .ConfigureAwait(false); if (result is null) diff --git a/src/AtleX.HaveIBeenPwned/Serialization/Json/JsonSerializerOptionsFactory.cs b/src/AtleX.HaveIBeenPwned/Serialization/Json/JsonSerializerOptionsFactory.cs new file mode 100644 index 0000000..19f69b3 --- /dev/null +++ b/src/AtleX.HaveIBeenPwned/Serialization/Json/JsonSerializerOptionsFactory.cs @@ -0,0 +1,22 @@ +using System.Text.Json; + +namespace AtleX.HaveIBeenPwned.Serialization.Json; + +/// +/// Represents a factory for +/// +internal static class JsonSerializerOptionsFactory +{ + /// + /// Creates a new instance of + /// + /// + /// The created + /// + public static JsonSerializerOptions Create() + { + var result = new JsonSerializerOptions(); + + return result; + } +} diff --git a/src/ConsoleApp1/ConsoleApp1.csproj b/src/ConsoleApp1/ConsoleApp1.csproj new file mode 100644 index 0000000..1d22a36 --- /dev/null +++ b/src/ConsoleApp1/ConsoleApp1.csproj @@ -0,0 +1,9 @@ + + + + Exe + net6.0 + enable + + + diff --git a/src/ConsoleApp1/Program.cs b/src/ConsoleApp1/Program.cs new file mode 100644 index 0000000..0fbc0ce --- /dev/null +++ b/src/ConsoleApp1/Program.cs @@ -0,0 +1,4 @@ +// See https://aka.ms/new-console-template for more information + + +Console.WriteLine("Hello, World!");