Class OverrideResultConverter<TValue, TError>
Converts Result<TValue, TError> to and from JSON. Register this converter to override the default deserialization behavior.
Inherited Members
Namespace: Recore.Text.Json.Serialization.Converters
Assembly: Recore.dll
Syntax
public sealed class OverrideResultConverter<TValue, TError> : JsonConverter<Result<TValue, TError>>
Type Parameters
Name | Description |
---|---|
TValue | |
TError |
Remarks
This converter is made to be used with a closed type and registered through Converters. It is not returned by Recore.Text.Json.Serialization.Converters.ResultConverter.CreateConverter(System.Type,System.Text.Json.JsonSerializerOptions).
Constructors
| Improve this Doc View SourceOverrideResultConverter(Func<JsonElement, Boolean>)
Initializes an instance of OverrideResultConverter<TValue, TError>.
Declaration
public OverrideResultConverter(Func<JsonElement, bool> deserializeAsValue)
Parameters
Type | Name | Description |
---|---|---|
Func<JsonElement, Boolean> | deserializeAsValue | A delegate that takes a JsonElement representing some JSON and returns
whether it should be deserialized as |
Methods
| Improve this Doc View SourceRead(ref Utf8JsonReader, Type, JsonSerializerOptions)
Deserializes JSON into Result<TValue, TError>. This method will call the delegate passed to the constructor to determine how to deserialize the JSON.
Declaration
public override Result<TValue, TError> Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
Parameters
Type | Name | Description |
---|---|---|
Utf8JsonReader | reader | |
Type | typeToConvert | |
JsonSerializerOptions | options |
Returns
Type | Description |
---|---|
Result<TValue, TError> |
Overrides
Write(Utf8JsonWriter, Result<TValue, TError>, JsonSerializerOptions)
Serializes Result<TValue, TError> as JSON.
Declaration
public override void Write(Utf8JsonWriter writer, Result<TValue, TError> value, JsonSerializerOptions options)
Parameters
Type | Name | Description |
---|---|---|
Utf8JsonWriter | writer | |
Result<TValue, TError> | value | |
JsonSerializerOptions | options |