JsonValueExtensionsToJsonTEnum(TEnum, JsonEnumFormat, String) Method

Converts the specified value to JsonValue.


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


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

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

Return Value

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).


ArgumentOutOfRangeExceptionformat is not one of the defined values.

See Also