# The pain of serializing unions and closed class hierarchies with System.Text.Json: Exploring the .NET 11 preview - Part 7

DevFeed: [The pain of serializing unions and closed class hierarchies with System.Text.Json: Exploring the .NET 11 preview - Part 7](<https://devfeed.tech/articles/the-pain-of-serializing-unions-and-closed-class-hierarchies-with-system-text-json-exploring-the-net-11-preview-part-7-51479.md>)

Original publisher: [Read original article](<https://andrewlock.net/exploring-the-dotnet-11-preview-7-the-pain-of-serializing-unions-and-closed-class-hierarchies-with-system-text-json/>)

Author: Andrew Lock

Published: 2026-09-01T10:00:00Z

Content type: tutorial

Language: en

Sources: [Andrew Lock | .NET Escapades](<https://devfeed.tech/sources/andrew-lock-net-escapades.md>)

Topics: [.NET](<https://devfeed.tech/topics/net.md>), [system.text.json](<https://devfeed.tech/topics/system-text-json.md>), [C#](<https://devfeed.tech/topics/csharp.md>), [Closed hierarchies](<https://devfeed.tech/topics/closed-hierarchies.md>), [JSON](<https://devfeed.tech/topics/json.md>), [union types](<https://devfeed.tech/topics/union-types.md>), [Programming](<https://devfeed.tech/topics/programming.md>)

Tags: [c-sharp](<https://devfeed.tech/tags/c-sharp.md>), [c-sharp-15](<https://devfeed.tech/tags/c-sharp-15.md>), [closed-hierarchies](<https://devfeed.tech/tags/closed-hierarchies.md>), [json](<https://devfeed.tech/tags/json.md>), [net](<https://devfeed.tech/tags/net.md>), [net-11](<https://devfeed.tech/tags/net-11.md>), [net-11-c-sharp](<https://devfeed.tech/tags/net-11-c-sharp.md>), [net-11-preview-7](<https://devfeed.tech/tags/net-11-preview-7.md>), [preview](<https://devfeed.tech/tags/preview.md>), [rust](<https://devfeed.tech/tags/rust.md>), [system-text-json](<https://devfeed.tech/tags/system-text-json.md>)

## AI overview

This tutorial examines how System.Text.Json handles union types and closed class hierarchies introduced in .NET 11 and C# 15. It compares the two approaches, demonstrates serialization and deserialization, and documents errors and compatibility edge cases encountered in .NET 11 Preview 7.

## Source excerpt

In this post I discuss the System.Text.Json support for unions and closed hierarchies coming in .NET 11, the decisions made, and some of the sharp edges I hit