JsonValueExtensionsToJson(NullableTimeSpan, JsonTimeFormat, Boolean) 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(
	this TimeSpan? value,
	JsonTimeFormat format = JsonTimeFormat.Auto,
	bool asString = true
)

Parameters

value  NullableTimeSpan
The value to convert.
format  JsonTimeFormat  (Optional)
Specifies the format of the value as a JSON value. This parameter is optional.
Default value: Auto, which applies Text if asString is , or Milliseconds if asString is .
asString  Boolean  (Optional)
to convert the value to a JsonValue with String Type; or to convert it to a JsonValue with Number Type, which is not applicable for all formats. This parameter is optional.
Default value: .

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 NullableTimeSpan. 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.
ArgumentExceptionasString is but format represents a string-only format.

See Also