Delegate Utf8JsonWriterAction<T>
- Namespace
- Cuemon.Extensions.Text.Json
- Assembly
- Cuemon.Extensions.Text.Json.dll
Represents the Write method of JsonConverter<T>.
public delegate void Utf8JsonWriterAction<in T>(Utf8JsonWriter writer, T value, JsonSerializerOptions options)
Parameters
writerUtf8JsonWriterThe Utf8JsonWriter to write to.
valueTThe value to convert to JSON.
optionsJsonSerializerOptionsAn object that specifies serialization options to use.
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 Utf8JsonWriterActionExample
{
public static void Demonstrate()
{
Utf8JsonWriterAction<Guid> writer = (jsonWriter, value, _) =>
jsonWriter.WriteStringValue(value.ToString("D"));
var converter = DynamicJsonConverter.Create<Guid>(writer: writer);
var json = JsonSerializer.Serialize(Guid.Parse("11111111-2222-3333-4444-555555555555"), new JsonSerializerOptions
{
Converters = { converter }
});
Console.WriteLine(json);
}
}