From 2084810036f695f0766c9cb972a3d6f1eea234cb Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sun, 3 May 2026 22:20:47 -0500 Subject: add extension to get json serializer settings --- src/slskd/Common/CommonExtensions.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/slskd/Common/CommonExtensions.cs b/src/slskd/Common/CommonExtensions.cs index 77db91ef..8e6d5603 100644 --- a/src/slskd/Common/CommonExtensions.cs +++ b/src/slskd/Common/CommonExtensions.cs @@ -555,9 +555,17 @@ namespace slskd /// The new object deserialized from the string. public static T FromJson(this string str) => JsonSerializer.Deserialize(str, GetJsonSerializerOptions()); - private static JsonSerializerOptions GetJsonSerializerOptions() + /// + /// Applies the standard json serializer options to the specified instance. + /// + /// The instance. + /// The instances with the standard options applied. + public static JsonSerializerOptions WithStandardOptions(this JsonSerializerOptions opt) + => GetJsonSerializerOptions(opt); + + private static JsonSerializerOptions GetJsonSerializerOptions(JsonSerializerOptions opt = null) { - var options = new JsonSerializerOptions(); + var options = opt ?? new JsonSerializerOptions(); options.Converters.Add(new IPAddressConverter()); options.Converters.Add(new JsonStringEnumConverter()); options.Converters.Add(new KnownUnsupportedTypeConverter()); -- cgit v1.2.3