using Confluent.Kafka; using System.Text.Json; namespace Serializers { public class JsonSerializer : ISerializer, IDeserializer { public byte[] Serialize(T data, SerializationContext context) { return JsonSerializer.SerializeToUtf8Bytes(data); } public T Deserialize(ReadOnlySpan data, bool isNull, SerializationContext context) { if (!isNull) { return JsonSerializer.Deserialize(data); } throw new Exception ("Data cannot be null"); } } }