0
개체를 serialize 할 때 문자열 표현 대신 enum의 속성 값을 가져 오려면 어떤 설정을 변경해야합니까? 나는 다음 수업을 듣는다.직렬화 할 때 문자열 표현 대신 enum의 int 값을 가져 오려면 어떤 설정을 변경해야합니까?
public class ProductModel
{
public long ProductId { get; set; }
public int ContainerType { get; set; }
public SolidForm SolidForm { get; set; }
}
(예를 들어) NOW ---> 내 JSON =
{ "ProductId" : 22222,
"ContainerType" : 1111,
"SolidForm" : "Solid"
}
하지만 나는 직렬화 후이 필요합니다. 내 객체의 모든 열거 형이 int로 변환하는 것이 원하는
{ "ProductId" : 22222,
"ContainerType" : 1111,
"SolidForm" : 1
}
(문자열로 열거 형되지 않음). JSON 직렬화
JsonSerializerSettings = new JsonSerializerSettings
{
DateFormatHandling = DateFormatHandling.MicrosoftDateFormat,
Error = delegate (object sender, ErrorEventArgs args)
{
args.ErrorContext.Handled = true;
}
}