using System.Net.Http.Json; using System.Text.Json; using DefaultJsonSerializer = System.Text.Json.JsonSerializer; namespace Foxcord.Serialization; public static class JsonSerializer { private static readonly JsonSerializerOptions Options = new() { PropertyNamingPolicy = JsonNamingPolicy.SnakeCaseLower, PropertyNameCaseInsensitive = true }; public static string Serialize(object? value) => DefaultJsonSerializer.Serialize(value, Options); public static byte[] SerializeToUtf8Bytes(object? value) => DefaultJsonSerializer.SerializeToUtf8Bytes(value, Options); public static TValue? Deserialize(string json) => DefaultJsonSerializer.Deserialize(json, Options); public static ValueTask DeserializeAsync(Stream json) => DefaultJsonSerializer.DeserializeAsync(json, Options); public static Task ReadAsJsonAsync(this HttpContent content) => content.ReadFromJsonAsync(Options); }