Converts the specified value to JsonValue.
Namespace: KGySoft.Json
Assembly: KGySoft.Json (in KGySoft.Json.dll) Version: 2.0.1
Syntax
public static JsonValue ToJson<TEnum>( this TEnum value, JsonEnumFormat format = JsonEnumFormat.PascalCase, string? flagsSeparator = null ) where TEnum : struct, new()
Parameters
- value
- Type: TEnum
The value to convert. - format (Optional)
- Type: KGySoft.JsonJsonEnumFormat
Specifies the format of the enum in the JSON value. This parameter is optional.
Default value: PascalCase. - flagsSeparator (Optional)
- Type: SystemString
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
Type: JsonValueA 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 . 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
Exception | Condition |
---|---|
ArgumentOutOfRangeException | format is not one of the defined values. |
See Also