Skip to content

Commit

Permalink
convert jsonDynamic to contentitem extension
Browse files Browse the repository at this point in the history
  • Loading branch information
giannik committed Jun 10, 2024
1 parent 6f422c3 commit 639282a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,10 @@ public void SetValue(string key, object? value)
return;
}
}

public override string ToString()
{
return _jsonObject.ToJsonString();
}
public static implicit operator JsonObject(JsonDynamicObject value) => value._jsonObject;

public static implicit operator JsonDynamicObject(JsonObject value) => new(value);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Text.Json.Dynamic;
using System.Text.Json.Nodes;
using System.Text.Json.Settings;
using System.Threading.Tasks;
Expand Down Expand Up @@ -230,5 +231,12 @@ public static ContentItem Merge(this ContentItem contentItem, object properties,

return contentItem;
}
public static ContentItem ToContentItem(this JsonDynamicObject jsonDynamic)
{
var contentItem = new ContentItem();
var contentProperties = jsonDynamic.ToString();
contentItem.Merge(JObject.Parse(contentProperties));
return contentItem;
}
}
}

0 comments on commit 639282a

Please sign in to comment.