JsonEnumFormat Enumeration

Specifies how .NET enums (assuming conventional C# Pascal casing) are formatted when converted to JSON by the ToJsonTEnum(TEnum, JsonEnumFormat, String) extension method.

Definition

Namespace: KGySoft.Json
Assembly: KGySoft.Json (in KGySoft.Json.dll) Version: 3.0.0
C#
public enum JsonEnumFormat

Members

PascalCase0 Represents Pascal casing, eg. EnumValue.
Assuming that enums already use Pascal casing as per .NET conventions this formatting preserves the original format. When using the ToJsonTEnum(TEnum, JsonEnumFormat, String) method it adjusts only the first character if that is not an upper case one.
CamelCase1 Represents camel casing, eg. enumValue.
Assuming that enums use Pascal casing as per .NET conventions this formatting adjusts the first character only. When using the ToJsonTEnum(TEnum, JsonEnumFormat, String) method it adjusts only the first character if that is not a lower case one.
LowerCase2 Represents lower casing, eg. enumvalue. Possible underscores are not removed from the result.
UpperCase3 Represents upper casing, eg. ENUMVALUE. Possible underscores are not removed from the result.
LowerCaseWithUnderscores4 Represents lower casing with underscores, eg. enum_value.
Assuming that enums use Pascal casing as per .NET conventions this formatting just inserts underscores before the originally upper case letters, except the first one. If the original value also contains underscores, then they might be duplicated in the result. For such enums use the LowerCase formatting instead.
UpperCaseWithUnderscores5 Represents upper casing with underscores, eg. ENUM_VALUE.
Assuming that enums use Pascal casing as per .NET conventions this formatting just inserts underscores before the originally upper case letters, except the first one. If the original value also contains underscores, then they might be duplicated in the result. For such enums use the UpperCase formatting instead.
LowerCaseWithHyphens6 Represents lower casing with hyphens, eg. enum-value.
Assuming that enums use Pascal casing as per .NET conventions this formatting just inserts hyphens before the originally upper case letters, except the first one. If the original value contains underscores, then they also will be preserved.
UpperCaseWithHyphens7 Represents upper casing with hyphens, eg. ENUM-VALUE.
Assuming that enums use Pascal casing as per .NET conventions this formatting just inserts hyphens before the originally upper case letters, except the first one. If the original value contains underscores, then they also will be preserved.
Number8 Represents numeric formatting of enum values even if they have named representation. The result JsonValue will have Number Type.
NumberAsString9 Represents numeric formatting of enum values even if they have named representation. The result JsonValue will have String Type.

See Also