Skip to content

Commit

Permalink
Legacy Storage - Convert objects to JSON nodes during migration
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertBeekman committed Mar 12, 2024
1 parent d7a0c2a commit da7a3e4
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/Artemis.Storage.Legacy/Entities/Workshop/EntryEntity.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Text.Json.Nodes;
using System.Text.Json;
using System.Text.Json.Nodes;

namespace Artemis.Storage.Legacy.Entities.Workshop;

Expand All @@ -16,7 +17,7 @@ internal class EntryEntity
public string ReleaseVersion { get; set; } = string.Empty;
public DateTimeOffset InstalledAt { get; set; }

public Dictionary<string, JsonNode>? Metadata { get; set; }
public Dictionary<string, object>? Metadata { get; set; }

public Storage.Entities.Workshop.EntryEntity Migrate()
{
Expand All @@ -31,7 +32,7 @@ public Storage.Entities.Workshop.EntryEntity Migrate()
ReleaseId = ReleaseId,
ReleaseVersion = ReleaseVersion,
InstalledAt = InstalledAt,
Metadata = Metadata ?? new Dictionary<string, JsonNode>()
Metadata = Metadata?.ToDictionary(kvp => kvp.Key, kvp => JsonSerializer.SerializeToNode(kvp.Value) ?? new JsonObject())
};
}
}

0 comments on commit da7a3e4

Please sign in to comment.