From ef7d69f222449d264ed8aad300a403d86ba36316 Mon Sep 17 00:00:00 2001 From: Felipe Lambert Date: Mon, 31 Jul 2023 12:26:12 -0300 Subject: [PATCH] add Deserializer --- fruit-consumer-azurefunction/FruitMessage.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/fruit-consumer-azurefunction/FruitMessage.cs b/fruit-consumer-azurefunction/FruitMessage.cs index a08ae80..537c65f 100644 --- a/fruit-consumer-azurefunction/FruitMessage.cs +++ b/fruit-consumer-azurefunction/FruitMessage.cs @@ -12,7 +12,7 @@ namespace Fruit.Consumer.AzureFunction { - public class FruitMessage : ISerializer + public class FruitMessage : ISerializer, IDeserializer { public DateTime? now { get; set; } public Fruit? fruit { get; set; } @@ -41,6 +41,11 @@ public byte[] Serialize(FruitMessage data, SerializationContext context) return ms.ToArray(); } } + + public FruitMessage Deserialize(ReadOnlySpan data, bool isNull, SerializationContext context) + { + return JsonConvert.DeserializeObject(Encoding.UTF8.GetString(data)); + } } public class LowercaseContractResolver : DefaultContractResolver {