diff --git a/docs/standard/serialization/system-text-json-overview.md b/docs/standard/serialization/system-text-json-overview.md index 8c1de2c225796..1907231a47f8b 100644 --- a/docs/standard/serialization/system-text-json-overview.md +++ b/docs/standard/serialization/system-text-json-overview.md @@ -3,6 +3,7 @@ title: "Serialize and deserialize JSON using C# - .NET" description: This overview describes the System.Text.Json namespace functionality for serializing to and deserializing from JSON in .NET. ms.date: "01/10/2020" no-loc: [System.Text.Json, Newtonsoft.Json] +zone_pivot_groups: dotnet-version helpviewer_keywords: - "JSON serialization" - "serializing objects" @@ -33,6 +34,27 @@ There are some limitations on what parts of the library that you can use from Vi For information about security threats that were considered when designing , and how they can be mitigated, see [`System.Text.Json` Threat Model](https://github.com/dotnet/runtime/blob/main/src/libraries/System.Text.Json/docs/ThreatModel.md). +## Thread safety + +* The `System.Text.Json` types are thread-safe, including: + +:::zone pivot="dotnet-5-0,dotnet-core-3-1" + +* +* +* +* +:::zone-end + +:::zone pivot="dotnet-6-0" + +* +* +* +* +* `JsonNode` +:::zone-end + ## Additional resources * [How to use the library](system-text-json-how-to.md) diff --git a/docs/standard/serialization/system-text-json-use-dom-utf8jsonreader-utf8jsonwriter.md b/docs/standard/serialization/system-text-json-use-dom-utf8jsonreader-utf8jsonwriter.md index 8f92bcecbac58..db4d24439fb57 100644 --- a/docs/standard/serialization/system-text-json-use-dom-utf8jsonreader-utf8jsonwriter.md +++ b/docs/standard/serialization/system-text-json-use-dom-utf8jsonreader-utf8jsonwriter.md @@ -43,7 +43,9 @@ The preceding code: * Assumes the JSON to analyze is in a string named `jsonString`. * Calculates an average grade for objects in a `Students` array that have a `Grade` property. * Assigns a default grade of 70 for students who don't have a grade. -* Counts students by incrementing a `count` variable with each iteration. An alternative is to call , as shown in the following example: +* Creates the `JsonDocument` instance in a [`using` statement](../../csharp/language-reference/keywords/using-statement.md) because `JsonDocument` implements `IDisposable`. After a `JsonDocument` instance is disposed, you lose access to all of its `JsonElement` instances also. To retain access to a `JsonElement` instance, make a copy of it before the parent `JsonDocument` instance is disposed. To make a copy, call . For more information, see [JsonDocument is IDisposable](system-text-json-migrate-from-newtonsoft-how-to.md#jsondocument-is-idisposable). + +The preceding example code counts students by incrementing a `count` variable with each iteration. An alternative is to call , as shown in the following example: :::code language="csharp" source="snippets/system-text-json-how-to/csharp/JsonDocumentDataAccess.cs" id="AverageGrades2"::: :::code language="vb" source="snippets/system-text-json-how-to/vb/JsonDocumentDataAccess.vb" id="AverageGrades2":::