mirror of
https://github.com/bitwarden/server.git
synced 2025-05-22 03:54:33 -05:00
Use static property for JsonSerializerOptions (#3923)
This commit is contained in:
parent
5237b522e5
commit
4c1d24b10a
@ -32,6 +32,10 @@ public static class CoreHelpers
|
||||
private static readonly Random _random = new Random();
|
||||
private static readonly string RealConnectingIp = "X-Connecting-IP";
|
||||
private static readonly Regex _whiteSpaceRegex = new Regex(@"\s+");
|
||||
private static readonly JsonSerializerOptions _jsonSerializerOptions = new()
|
||||
{
|
||||
PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Generate sequential Guid for Sql Server.
|
||||
@ -778,22 +782,12 @@ public static class CoreHelpers
|
||||
return new T();
|
||||
}
|
||||
|
||||
var options = new JsonSerializerOptions
|
||||
{
|
||||
PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
|
||||
};
|
||||
|
||||
return System.Text.Json.JsonSerializer.Deserialize<T>(jsonData, options);
|
||||
return System.Text.Json.JsonSerializer.Deserialize<T>(jsonData, _jsonSerializerOptions);
|
||||
}
|
||||
|
||||
public static string ClassToJsonData<T>(T data)
|
||||
{
|
||||
var options = new JsonSerializerOptions
|
||||
{
|
||||
PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
|
||||
};
|
||||
|
||||
return System.Text.Json.JsonSerializer.Serialize(data, options);
|
||||
return System.Text.Json.JsonSerializer.Serialize(data, _jsonSerializerOptions);
|
||||
}
|
||||
|
||||
public static ICollection<T> AddIfNotExists<T>(this ICollection<T> list, T item)
|
||||
|
Loading…
x
Reference in New Issue
Block a user