[]
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.
public static JsonCoder<T> Optional<T>(JsonCoder<T> coder, T defValue)
Type | Name | Description |
---|---|---|
JsonCoder<T> | coder | A JsonCoder<T> to encode and decode the value. |
T | defValue | The default value. |
Type | Description |
---|---|
JsonCoder<T> | A JsonCoder<T> with the default value handling. |
Name | Description |
---|---|
T | The type of the value. |
Skips empty objects during serialization and deserializes undefined values as a default object.
public static JsonCoder<T> Optional<T>(this JsonCoder<T> coder)
Type | Name | Description |
---|---|---|
JsonCoder<T> | coder | A JsonCoder<T> to encode and decode the value. |
Type | Description |
---|---|
JsonCoder<T> | A JsonCoder<T> that handles optional values. |
Name | Description |
---|---|
T | The type of the object to be encoded and decoded. |