What setting should I change to get the property value of an enum instead of its string representation when serializing an object? I have the following class.
public class ProductModel
{
public long ProductId { get; set; }
public int ContainerType { get; set; }
public SolidForm SolidForm { get; set; }
}
(for example) NOW ---> my json =
{ "ProductId" : 22222,
"ContainerType" : 1111,
"SolidForm" : "Solid"
}
but I need this after serialization. (not enum as string)
{ "ProductId" : 22222,
"ContainerType" : 1111,
"SolidForm" : 1
}
I want that all enums in my object converted to int.
this my settings of Json Serialization
JsonSerializerSettings = new JsonSerializerSettings
{
DateFormatHandling = DateFormatHandling.MicrosoftDateFormat,
Error = delegate (object sender, ErrorEventArgs args)
{
args.ErrorContext.Handled = true;
}
}