Skip to content

Commit 0c86a4a

Browse files
authored
Fixed second code sample with readonly converters collection.
Partly fixes #43178.
1 parent e79a6cf commit 0c86a4a

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

docs/standard/serialization/system-text-json/snippets/how-to/csharp/RoundtripStackOfT.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,8 @@ public static void Run()
1313

1414
Console.WriteLine("Deserialize JSON string [1, 2, 3] with custom converter, then serialize it back to JSON.");
1515
// <Register>
16-
var options = new JsonSerializerOptions
17-
{
18-
Converters = { new JsonConverterFactoryForStackOfT() },
19-
};
16+
var options = new JsonSerializerOptions();
17+
options.Converters.Add(new JsonConverterFactoryForStackOfT());
2018
// </Register>
2119
stack = JsonSerializer.Deserialize<Stack<int>>("[1, 2, 3]", options)!;
2220
serialized = JsonSerializer.Serialize(stack, options);

0 commit comments

Comments
 (0)