Skip to content

Instantly share code, notes, and snippets.

View AndyButland's full-sized avatar

Andy Butland AndyButland

View GitHub Profile
"gotoPageOnSubmit": "eab72f13-b22e-46d5-b270-9c196e49a53b"
public Guid? GotoPageOnSubmit { get; set; }
"route": {
"path": "/contact-us/",
"startItem": {
"id": "ca4249ed-2b23-4337-b522-63cabe5587d1",
"path": "home"
}
}
using Umbraco.Cms.Core.Models.PublishedContent;
using Umbraco.Cms.Core.PropertyEditors;
using Umbraco.Cms.Core.PropertyEditors.DeliveryApi;
using Umbraco.Forms.Core.Models;
using Umbraco.Forms.Core.Models.Api;
using Umbraco.Forms.Core.Services;
namespace Umbraco.Forms.Core.PropertyEditors.ValueConverters
{
[DefaultPropertyValueConverter]
"contactForm": {
"id": "3623b232-9296-4bf0-b16c-57801dc4f296",
"form": {
"id": "3623b232-9296-4bf0-b16c-57801dc4f296",
"name": "Contact Form",
"pages": [ ... ]
}
}
"contactForm": {
"id": "3623b232-9296-4bf0-b16c-57801dc4f296",
"form": null
}
{
"name": "Contact Us",
"route": {
"path": "/contact-us/",
"startItem": {
"id": "ca4249ed-2b23-4337-b522-63cabe5587d1",
"path": "home"
}
},
"id": "4a1f4198-e143-48ba-a0f5-1a7ef2df23aa",
internal class MyApiPostedValuesConverter : JsonConverter<IDictionary<string, IList<string>>>
{
public override bool CanConvert(Type typeToConvert) => true;
public override IDictionary<string, IList<string>> Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
if (reader.TokenType != JsonTokenType.StartObject)
{
throw new JsonException(GetJsonExceptionMessage("Start object token not found"));
}
internal class MyApiPostedValuesConverter : JsonConverter
{
public override bool CanConvert(Type objectType) => objectType == typeof(IDictionary<string, IList<string>>);
public override object ReadJson(JsonReader reader, Type objectType, object? existingValue, JsonSerializer serializer)
{
var properties = JToken.Load(reader).Cast<JProperty>().ToList();
var result = new Dictionary<string, IList<string>>();
foreach (JProperty property in properties)
[JsonConverter(typeof(MyApiPostedValuesConverter))]
public IDictionary<string, IList<string>> Values { get; set; }