From ad72e99c62d1233bcc71aab7031fcc0f8905abf1 Mon Sep 17 00:00:00 2001 From: gurkanguran Date: Wed, 28 Jun 2023 18:15:32 +0200 Subject: [PATCH] Fix dynamic deserilization in proto actor (#4168) --- src/modules/Elsa.ProtoActor/Elsa.ProtoActor.csproj | 1 + .../Extensions/ProtoInputExtensions.cs | 11 ++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/modules/Elsa.ProtoActor/Elsa.ProtoActor.csproj b/src/modules/Elsa.ProtoActor/Elsa.ProtoActor.csproj index 5d8372651..ea89a376e 100644 --- a/src/modules/Elsa.ProtoActor/Elsa.ProtoActor.csproj +++ b/src/modules/Elsa.ProtoActor/Elsa.ProtoActor.csproj @@ -30,6 +30,7 @@ + diff --git a/src/modules/Elsa.ProtoActor/Extensions/ProtoInputExtensions.cs b/src/modules/Elsa.ProtoActor/Extensions/ProtoInputExtensions.cs index 3c0040e79..3dc6167d2 100644 --- a/src/modules/Elsa.ProtoActor/Extensions/ProtoInputExtensions.cs +++ b/src/modules/Elsa.ProtoActor/Extensions/ProtoInputExtensions.cs @@ -1,11 +1,20 @@ +using System.Dynamic; using System.Text.Json; +using System.Text.Json.Nodes; using Elsa.ProtoActor.Protos; +using Elsa.Workflows.Core.Serialization.Converters; namespace Elsa.ProtoActor.Extensions; internal static class ProtoInputExtensions { - public static IDictionary Deserialize(this Input input) => input.Data.ToDictionary(x => x.Key, x => JsonSerializer.Deserialize(x.Value.Text)!); + public static IDictionary Deserialize(this Input input) + { + var jsonSerializerOptions = new JsonSerializerOptions(); + jsonSerializerOptions.Converters.Add(new ExpandoObjectConverterFactory()); + + return input.Data.ToDictionary(x => x.Key, x => JsonSerializer.Deserialize(x.Value.Text, jsonSerializerOptions)!); + } public static Input Serialize(this IDictionary input) {