Files
sanstudent/Common/Extensions/JsonExtensions.cs
aherman-san b8f03bf6d3
All checks were successful
SanStudent Multi-Project Deployment / deploy-api (push) Successful in 41s
SanStudent Multi-Project Deployment / deploy-frontadmin (push) Successful in 41s
SanStudent Multi-Project Deployment / deploy-frontstudent (push) Successful in 40s
Add project
2026-03-07 11:14:26 +01:00

12 lines
473 B
C#

using System.Text.Json;
namespace Common.Extensions
{
public static class JsonExtensions
{
private static JsonSerializerOptions _jso = new() { PropertyNameCaseInsensitive = true, PropertyNamingPolicy = JsonNamingPolicy.CamelCase };
public static string ToJson<T>(this T source) => JsonSerializer.Serialize(source, _jso);
public static T FromJson<T>(this string source) => JsonSerializer.Deserialize<T>(source, _jso) ?? default!;
}
}