[]
        
(Showing Draft Content)

GrapeCity.ActiveReports.Core.Rdl.Persistence.Json.JsonCoders.Optional

Optional Method

Optional<T>(JsonCoder<T>, T)

Encodes the specified default value as undefined and skips it during serialization. During deserialization, the undefined value will be replaced with the specified default value.

Declaration
public static JsonCoder<T> Optional<T>(JsonCoder<T> coder, T defValue)
Parameters
Type Name Description
JsonCoder<T> coder

A JsonCoder<T> to encode and decode the value.

T defValue

The default value.

Returns
Type Description
JsonCoder<T>

A JsonCoder<T> with the default value handling.

Type Parameters
Name Description
T

The type of the value.

Optional<T>(JsonCoder<T>)

Skips empty objects during serialization and deserializes undefined values as a default object.

Declaration
public static JsonCoder<T> Optional<T>(this JsonCoder<T> coder)
Parameters
Type Name Description
JsonCoder<T> coder

A JsonCoder<T> to encode and decode the value.

Returns
Type Description
JsonCoder<T>

A JsonCoder<T> that handles optional values.

Type Parameters
Name Description
T

The type of the object to be encoded and decoded.