Category "system.text.json"

System.Text.Json 6.0.2 Serialize error - trying to load System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1

We are using C# .Net Framework 4.7.2, JsonSerializer in System.Text.Json Version 6.0.2. Solution builds fine. We get a runtime error when Serializing: Could no

Where does .NET 6's System.Text.Json source generation store its code?

I have tried to implement Source Generation-based JSON serilization, based on MS Docs: How to use source generation in System.Text.Json. My code is as follows:

JsonElement and null conditional operator (KeyNotFoundException)

I have a JSON object that I get from API and I need to check for error in the response of the JSON. However, when there is no error the error value is not prese

Formatting DateTime in ASP.NET Core 3.0 using System.Text.Json

I am migrating a web API from .NET Core 2.2 to 3.0 and want to use the new System.Text.Json. When using Newtonsoft I was able to format DateTime using the code

How to pretty print using System.Text.Json for unknown object

Using System.Text.Json i can pretty print json using serialization option. var options = new JsonSerializerOptions{ WriteIndented = true }; jsonString = JsonSer

How to serialize enum as string in Function App running on .net5 with OpenAPI/Swagger?

I am exploring Function App running on .net5 in the new isolated mode. I have HTTP triggered functions that I want to advertise via OpenAPI / Swagger. To do so,

Get .NET Core JsonSerializer to serialize private members

I have a class with a private List<T> property which I would like to serialize/deserialize using the JsonSerializer. Use of the JsonPropertyAttribute does

ASP.NET MVC Core API Serialize Enums to String

How to serialize Enum fields to String instead of an Int in ASP.NET MVC Core 3.0? I'm not able to do it the old way. services.AddMvc().AddJsonOptions(opts =&g

How to write an attribute for replacing sensitive data on serialization using System.Text.Json

I am logging my parameter models on console. In there I don't want to display the user password on login/register raw in logs, I want *. My limitation is that I

Write List<double> to Json array without indentation using System.Text.Json

NB: I am using System.Text.Json not JSON.NET for which there is similar question that has been answered. I need the same answer but for System.Text.Json. I wou

How to create a JSON body with PowerShell which is Deserializable by .NET6 when using az rest to call a .NET6 Azure Function

We are using AzureCLI to be able to call an Azure Function endpoint upon a successful deployment. The call to get token works and the call to our azure functio

System.Text.Json: How do I specify a custom name for an enum value?

Using the System.Text.Json serializer capabilities in .NET Core, how can I specify a custom value for an enum value, similar to JsonPropertyName? For example:

Converting a POCO object with JsonPropertyName decorations into a URL query string

Is there an .NET API to convert a POCO object with JsonPropertyName decorations into a properly encoded URL query string? For example, for: public record AuthEn

Equivalent of JObject in System.Text.Json

I have DTO class that has a property of type JObject. This DTO class is send/receive over HTTP between multiple services. JObject is used because the ExtractedD

Equivalent of JObject in System.Text.Json

I have DTO class that has a property of type JObject. This DTO class is send/receive over HTTP between multiple services. JObject is used because the ExtractedD

.net Core 3 [JsonIgnore] not working when requesting single resource

in my .net Core 3.0 Api the [JsonIgnore] Attribute is not working as excepted. Im using System.Text.Json instead of the old Newtonsoft.Json When i'm using my