JsonValueExtensionsToJsonTEnum(TEnum, JsonEnumFormat, String) Method

Converts the specified value to JsonValue.

Definition

Namespace: KGySoft.Json
Assembly: KGySoft.Json (in KGySoft.Json.dll) Version: 3.0.0
C#
public static JsonValue ToJson<TEnum>(
	this TEnum value,
	JsonEnumFormat format = JsonEnumFormat.PascalCase,
	string? flagsSeparator = null
)
where TEnum : struct, new()

Parameters

value  TEnum
The value to convert.
format  JsonEnumFormat  (Optional)
Specifies the format of the enum in the JSON value. This parameter is optional.
Default value: PascalCase.
flagsSeparator  String  (Optional)
Specifies the separator if value consists of multiple flags. This parameter is optional.
Default value: , which uses the default ", " separator.

Type Parameters

TEnum
The type of the enumeration. Must be an Enum type.

Return Value

JsonValue
A JsonValue instance that is the JSON representation of the specified value.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type TEnum. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

Exceptions

ArgumentOutOfRangeExceptionformat is not one of the defined values.

See Also