I have two classes that look like this:
public class Field
{
public string Name { get; set; }
public FieldType FieldType { get; set; }
}
public class FieldType
{
public Dictionary<string, object> Settings { get; set; }
public static readonly FieldType Text = new FieldType()
{
Settings = new Dictionary<string, object>() { { "setting 1", "" }, { "setting 2", "" } }
};
}
And I'd like to deserialize the following json:
{
"name": "First Name",
"fieldType": "Text"
}
So that the FieldType property is correctly assigned the static FieldType of 'Text'.
Do I need to modify my FieldType class? Or do I need some custom JsonSerializerSettings?
Currently I'm getting the error: Error converting value "Text" to type 'FieldType'. Path 'fieldType