diff options
| author | JP Dillingham <jp@dillingham.me> | 2026-10-26 09:53:21 -0500 |
|---|---|---|
| committer | JP Dillingham <jp@dillingham.me> | 2026-10-26 09:53:21 -0500 |
| commit | 3e61fd10d693a45c520b7436097919bc68eface0 (patch) | |
| tree | fe4bebb1e8acb2cd26128250d20a321307135217 /src | |
| parent | 06a7849bd93108a4f96427e26007494da276382b (diff) | |
| download | slskd-3e61fd10d693a45c520b7436097919bc68eface0.tar.gz | |
cache default serializer options
Diffstat (limited to 'src')
| -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. |
