Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert jsonDynamic to contentitem extension #16283

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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();
}
giannik marked this conversation as resolved.
Show resolved Hide resolved
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;
}
giannik marked this conversation as resolved.
Show resolved Hide resolved
}
}