Question: I have a JSON document like

```
{
   "outer":{
      "inner":{ ... }
   }
}

```

How can I deserialize the value of `"inner"` (the `{ ... }`) into some type `MyType` using `System.Text.Json`?

Answer: 
In .NET 5, you can deserialize the JSON to an anonymous type that wraps the required type:

```
var myType = JsonSerializerExtensions.DeserializeAnonymousType(jsonString, 
                                                               new { outer = new { inner = default(MyType) } })
    ?.outer?.inner;

```

Using the extension methods from *[Deserialize anonymous type with System.Text.Json](https://stackoverflow.com/q/59313256/3744182)*:

```
public static partial class JsonSerializerExtensions
{
    public static T DeserializeAnonymousType<T>(string json, T anonymousTypeObject, JsonSerializerOptions options = default)
        => JsonSerializer.Deserialize<T>(json, options);

    public static ValueTask<TValue> DeserializeAnonymousTypeAsync<TValue>(Stream stream, TValue anonymousTypeObject, JsonSerializerOptions options = default, CancellationToken cancellationToken = default)
        => JsonSerializer.DeserializeAsync<TValue>(stream, options, cancellationToken); // Method to deserialize from a stream added for completeness
}

```

This should be more performant than deserializing to an intermediate `JsonDocument`. But note this will not work in .NET Core 3.x as that version does not support deserializing to types with parameterized constructors.

Demo fiddle [here](https://dotnetfiddle.net/ixK00V).
You can try using the JsonDocument class. A section in the link below explains how it works with sample code.

<https://devblogs.microsoft.com/dotnet/try-the-new-system-text-json-apis/>