Convert object to System.Text.Json.JsonElement
In .NET 6 methods are being added to JsonSerializer to serialize an object directly to a JsonElement or JsonDocument: public static partial class JsonSerializer { public static JsonDocument SerializeToDocument<TValue>(TValue value, JsonSerializerOptions? options = null); public static JsonDocument SerializeToDocument(object? value, Type inputType, JsonSerializerOptions? options = null); public static JsonDocument SerializeToDocument<TValue>(TValue value, JsonTypeInfo<TValue> jsonTypeInfo); public static JsonDocument … Read more