From 965a6ef0aee92add90d4863cd7ef57899d2629dc Mon Sep 17 00:00:00 2001 From: Tom Dykstra Date: Mon, 14 Dec 2020 10:27:38 -0800 Subject: [PATCH] Note no partial reads --- .../serialization/system-text-json-converters-how-to.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/standard/serialization/system-text-json-converters-how-to.md b/docs/standard/serialization/system-text-json-converters-how-to.md index 771c595b430c7..d922e6e07ef23 100644 --- a/docs/standard/serialization/system-text-json-converters-how-to.md +++ b/docs/standard/serialization/system-text-json-converters-how-to.md @@ -1,7 +1,7 @@ --- title: "How to write custom converters for JSON serialization - .NET" description: "Learn how to create custom converters for the JSON serialization classes that are provided in the System.Text.Json namespace." -ms.date: 12/09/2020 +ms.date: 12/14/2020 no-loc: [System.Text.Json, Newtonsoft.Json] zone_pivot_groups: dotnet-version helpviewer_keywords: @@ -77,7 +77,7 @@ The preceding code is the same as what is shown in the [Support Dictionary with The following steps explain how to create a converter by following the basic pattern: * Create a class that derives from where `T` is the type to be serialized and deserialized. -* Override the `Read` method to deserialize the incoming JSON and convert it to type `T`. Use the that is passed to the method to read the JSON. +* Override the `Read` method to deserialize the incoming JSON and convert it to type `T`. Use the that is passed to the method to read the JSON. You don't have to worry about handling partial data, as the serializer passes all the data for the current JSON scope. So it isn't necessary to call or or to validate that returns `true`. * Override the `Write` method to serialize the incoming object of type `T`. Use the that is passed to the method to write the JSON. * Override the `CanConvert` method only if necessary. The default implementation returns `true` when the type to convert is of type `T`. Therefore, converters that support only type `T` don't need to override this method. For an example of a converter that does need to override this method, see the [polymorphic deserialization](#support-polymorphic-deserialization) section later in this article. @@ -370,7 +370,7 @@ This null-handling behavior is primarily to optimize performance by skipping an ::: zone pivot="dotnet-5-0" To enable a custom converter to handle `null` for a reference or value type, override to return `true`, as shown in the following example: -:::code language="csharp" source="snippets/system-text-json-how-to-5-0/csharp/CustomConverterHandleNull.cs" highlight="19"::: +:::code language="csharp" source="snippets/system-text-json-how-to-5-0/csharp/CustomConverterHandleNull.cs" highlight="18"::: ::: zone-end ## Other custom converter samples