Update flowchart JSON converter to handle undefined connections array

This commit is contained in:
Sipke Schoorstra 2023-06-30 11:23:12 +02:00
parent a11a4a0b45
commit 299f9248f0

View file

@ -138,6 +138,9 @@ public class FlowchartJsonConverter : JsonConverter<Activities.Flowchart>
private static ICollection<Connection> DeserializeConnections(JsonElement connectionsElement, IDictionary<string, IActivity> activityDictionary, JsonSerializerOptions options)
{
if(connectionsElement.ValueKind == JsonValueKind.Undefined)
return new List<Connection>();
// To not break existing workflow definitions, we need to support the old connection format.
var useOldConnectionConverter = connectionsElement.EnumerateArray().Any(x => x.TryGetProperty("sourcePort", out var sourcePort) && sourcePort.ValueKind == JsonValueKind.String);