diff options
| author | JP Dillingham <jp@dillingham.me> | 2026-11-07 23:16:26 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-11-07 23:16:26 -0600 |
| commit | cefdcd02e28b1f02f546002fdd475de4fa03e839 (patch) | |
| tree | 95bb26f4ed7b60e3739bcd884966a19be1e9ee07 /src/slskd/Common/CommonExtensions.cs | |
| parent | 2b827344d11e7490b323defa898264cadbdb6089 (diff) | |
| parent | dbc308d5e408a2e194a0c70a8fc7592f776aaf11 (diff) | |
| download | slskd-cefdcd02e28b1f02f546002fdd475de4fa03e839.tar.gz | |
Merge pull request #1913 from slskd/bugs
Fix a random assortment of bugs
Diffstat (limited to 'src/slskd/Common/CommonExtensions.cs')
| -rw-r--r-- | src/slskd/Common/CommonExtensions.cs | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/slskd/Common/CommonExtensions.cs b/src/slskd/Common/CommonExtensions.cs index 95721163..47e4aee1 100644 --- a/src/slskd/Common/CommonExtensions.cs +++ b/src/slskd/Common/CommonExtensions.cs @@ -53,6 +53,8 @@ namespace slskd /// </summary> public static class CommonExtensions { + private static readonly JsonSerializerOptions DefaultJsonSerializerOptions = GetJsonSerializerOptions(); + /// <summary> /// Times this Task out after the specified TimeSpan. /// </summary> @@ -358,7 +360,7 @@ namespace slskd /// </summary> /// <param name="obj">The object to serialize.</param> /// <returns>A string containing the serialized object.</returns> - public static string ToJson(this object obj) => JsonSerializer.Serialize(obj, GetJsonSerializerOptions()); + public static string ToJson(this object obj) => JsonSerializer.Serialize(obj, DefaultJsonSerializerOptions); /// <summary> /// Serializes this object to yaml. @@ -481,7 +483,7 @@ namespace slskd /// <typeparam name="T">The type to which to deserialize the string.</typeparam> /// <param name="str">The string to deserialize.</param> /// <returns>The new object deserialized from the string.</returns> - public static T FromJson<T>(this string str) => JsonSerializer.Deserialize<T>(str, GetJsonSerializerOptions()); + public static T FromJson<T>(this string str) => JsonSerializer.Deserialize<T>(str, DefaultJsonSerializerOptions); /// <summary> /// Applies the standard json serializer options to the specified instance. |
