Delegate Utf8JsonReaderFunc<T>
- Namespace
- Cuemon.Extensions.Text.Json
- Assembly
- Cuemon.Extensions.Text.Json.dll
Represents the Read method of JsonConverter<T>.
public delegate T Utf8JsonReaderFunc<out T>(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
Parameters
readerUtf8JsonReaderThe Utf8JsonReader to read from.
typeToConvertTypeThe type to convert.
optionsJsonSerializerOptionsAn object that specifies serialization options to use.
Returns
- T
The converted value.
Type Parameters
TThe type of object or value handled by the converter.
- Extension Methods
Examples
The following example demonstrates how a
using System;
using System.Text.Json;
using Cuemon.Extensions.Text.Json;
namespace MyApp.Examples;
public static class Utf8JsonReaderFuncExample
{
public static void Demonstrate()
{
Utf8JsonReaderFunc<Guid> reader = (ref Utf8JsonReader jsonReader, Type _, JsonSerializerOptions __) =>
Guid.Parse(jsonReader.GetString());
var converter = DynamicJsonConverter.Create<Guid>(reader: reader);
var result = JsonSerializer.Deserialize<Guid>("\"11111111-2222-3333-4444-555555555555\"", new JsonSerializerOptions
{
Converters = { converter }
});
Console.WriteLine(result);
}
}