Questions tagged [system.text.json]

System.Text.Json is the built-in JSON facilities added in .NET Core 3.0.

The System.Text.Json namespace provides high-performance, low-allocating, and standards-compliant capabilities to process JSON, which includes serializing objects to JSON text and deserializing JSON text to objects, with UTF-8 support built-in. It also provides types to read and write JSON text encoded as UTF-8, and to create an in-memory document object model (DOM) for random access of the JSON elements.

Additional details can be found in the how to article.

973 questions
0
votes
1 answer

Access value in JsonConverter.CanConvert()

Is it possible to convert a string to a TimeSpan object using a custom JsonConverter, but have it only convert when the string is in the format "hh:mm:ss"? I've looked at building a custom JsonConverter but the CanConvert() method only accepts a…
David Klempfner
  • 8,700
  • 20
  • 73
  • 153
0
votes
0 answers

dotnet core 3.1 json deserialization not working (System.Text.Json)

Using the System.Text.Json deserializer doesn't produce the expected results. There are no errors thrown, just a list without values....all object properties are null. Here is a working example: https://dotnetfiddle.net/QYrvy5 Here is the code in…
Will Lopez
  • 2,089
  • 3
  • 40
  • 64
0
votes
0 answers

How to ignore global JsonStringEnumConverter for specific enum type

Is there a way to annotate a POCO so that the JsonStringEnumConverter is ignored? I currently have this configured in my Startup class: mvcBuilder.AddJsonOptions(options => { options.JsonSerializerOptions.Converters.Add(new…
0
votes
1 answer

How to handle nuget packages with different dependencies?

I maintain a number of nuget packages that uses JSON and/or SQL server. Currently, they have dependencies on Newtonsoft.Json and System.Data.SqlClient but I got requests for supporting System.Text.Json and Microsoft.Data.SqlClient. Updating the code…
adrianm
  • 14,468
  • 5
  • 55
  • 102
0
votes
2 answers

JsonConverter on F# type field is not invoked

For the code below type MyConverter = inherit JsonConverter() ..... type MyType = { [)>] date: DateTime } JsonSerializer.Deserialize("{\"date\": \"2020-10-20\"}",…
dr11
  • 5,166
  • 11
  • 35
  • 77
0
votes
2 answers

Access nested values in json using System.Text.Json

I have a JSON file returned from a system that looks like this: { "value1": "Hello", "value2": "World", "result": { "stats": { "count":"1" } } } Getting to the values "Value1" and "Value2" is…
0
votes
1 answer

Deserialise JSON iin C# using system.text.json with complex property name

I am trying to deserialise JSON files that have been created by a third party tool. The files contain a property that can look like the below: "RECIPE": [{ "ctPoint_0": { "endTemperature": 25, "hours":…
Dave
  • 142
  • 7
0
votes
0 answers

.Net Core JsonSerializer - How to disable encoding of special characters

I'm using the new Json Serializer included in .Net Core (not Newtonsoft). I am enconding a phone number in an object with the country code, so I have an object with a string property which holds the number. Example: public class MyObject { …
Cristopher Rosales
  • 476
  • 1
  • 4
  • 14
0
votes
1 answer

How can I produce JSON without strangely slash character by JsonSerializer?

The JsonSerializer I am using is System.Text.Json; in .net core 3.1 Here are two projects, one is project A, the other is project B. Here is the code of project A: namespace WebApplication1.Controllers { [Route("api/")] public class…
Melon NG
  • 2,568
  • 6
  • 27
  • 52
0
votes
1 answer

How can I get to know which type JSON returns by JsonSerializer.Deserialize?

Now I am using the JsonSerializer.Deserialize from System.Text.Json to deserialize from string to model. However, there are two situations while I get JSON from the third-party API of remote server. When everything runs well, it will return the JSON…
Melon NG
  • 2,568
  • 6
  • 27
  • 52
0
votes
0 answers

Add a pair in JsonDocument

I am migrating from Json.NET - Newtonsoft to the new System.Text.Json. In the former source, JObject had the Add method, however I cannot find a similar function for JsonElement. How would be the way to add a pair to the json object?
kokokok
  • 1,030
  • 1
  • 9
  • 26
0
votes
1 answer

Replacing System.Text.Json with Manatee.Json for serialization in .NET Core 3

Background I want to provide some JsonSchema from my .NET Core 3 application, as well as other objects serialized into JSON. Since Manatee.Json is frequently updated and provides good support for JsonSchema, they are my preferred choice. At the same…
pekaaw
  • 2,309
  • 19
  • 18
0
votes
1 answer

Serializing Manatee.Json in .NET Core 3

Background I want to provide some JsonSchema from my .NET Core 3 application, as well as other objects serialized into JSON. Since Manatee.Json is frequently updated and provides good support for JsonSchema, they are my preferred choice. At the same…
pekaaw
  • 2,309
  • 19
  • 18
0
votes
0 answers

Thread pool starvation in docker container

I'm experiencing this kind of problem for the first time. I'm running an application in a container with some hosted services (AspNet, Core C# 8.0, Docker container Linux). The first service do a big data ingestion in my database. I will explain…
Rob None
  • 479
  • 2
  • 9
  • 22
0
votes
1 answer

Deserialize Multidimensional JSON array with ASP.NET Core

I have been trying for a few days to find this issue, perhaps I am missing something. I followed the recommendations from Microsoft when I built my sample application based on…
exaas
  • 43
  • 1
  • 4