system.text.json Questions

3

It's my understanding that you can use this setting to get around the issue of getting the following error when you have circular references defined in your object model: JsonException: A possible ...
Snide asked 12/12, 2020 at 4:36

4

Solved

I'm trying to use the System.Text.Json.JsonSerializer to deserialize the model partially, so one of the properties is read as string that contains the original JSON. public class SomeModel { publ...
Latonialatoniah asked 25/2, 2020 at 18:55

2

Solved

I'm receiving a response from a web api call as a stream and need to deserialize it to a model. This is a generic method, so I can't say which parts of code will use this and what's the response pa...
Duffy asked 22/10, 2019 at 21:13

2

Solved

I can't figure out why System.Text.Json won't deserialize this simple JSON string to my specified .NET type. I'm getting the Each parameter in the deserialization constructor on type 'MenuItem' mus...
Tortious asked 18/2, 2022 at 23:37

3

I updated an ASP.NET Core 2.2 API to ASP.NET Core 3.0 and I am using System.Json: services .AddMvc() .SetCompatibilityVersion(CompatibilityVersion.Version_3_0) .AddJsonOptions(x => {}) I ...
Scenography asked 15/11, 2019 at 22:15

1

Note 1 : I do NOT want to use newtonsoft.json ! Note 2 : This is not a duplicate, other answers use newtonsoft.json ! Note 3 : using .Net 5. How do I remove a property from a Json string with Syste...
Fantastic asked 24/4, 2022 at 7:43

5

Solved

So when I have a JsonNode I can just ask if it's a JsonObject or a JsonArray and work with those. But when the node is an actual value, how do I know whether it's a string, number or boolean? Of co...
Matias asked 23/3, 2022 at 13:18

3

Solved

I recently upgraded a solution to be all .NET Core 3 and I have a class that requires the class variables to be fields. This is a problem since the new System.Text.Json.JsonSerializer doesn't suppo...
Hurried asked 27/9, 2019 at 18:25

2

Solved

If I receive JSON which is beyond my control, which has a property as follows. {"allow":"true"} and I want that to map to a bool property in C#. I saw that I can do similar for...
Overstate asked 11/1, 2023 at 22:18

5

Solved

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 => { opts.JsonSerializerOptions.Conv...

1

It seems that if an object is an IEnumerable, Json ignores its fields and serialise the enumerable. For example, for a class like below, Title is not serialised. I have found almost the same questi...
Mcavoy asked 29/11, 2022 at 13:55

2

Solved

I have a multi-level polymorphic type hierarchy that I previously serialized using the data contract serializers. I would like to convert that to System.Text.Json using the new type hierarchy suppo...
Vincenty asked 28/11, 2022 at 17:45

7

Solved

In ASP.NET Core 3.0 Web API project, how do you specify System.Text.Json serialization options to serialize/deserialize Pascal Case properties to Camel Case and vice versa automatically? Given a mo...
Bennie asked 20/10, 2019 at 19:45

6

Solved

I've combed through the MS docs but cannot find an attribute equivalent to the NewtonSoft JsonPropertyRequired. What I'm looking for is this: public class Videogame { [JsonProperty(Required = Requ...
Softwood asked 18/10, 2019 at 2:36

16

Solved

I try to migrate from Newtonsoft.Json to System.Text.Json. I want to deserialize abstract class. Newtonsoft.Json has TypeNameHandling for this. Is there any way to deserialize abstract class via Sy...
Yankee asked 24/9, 2019 at 6:31

2

Solved

In the new System.Text.Json; namespace is there something like IContractResolver i am trying to migrate my project away from Newtonsoft. This is one of the classes i am trying to move: public cla...

3

Solved

I'm trying to read and parse a large JSON file that cannot fit in memory with the new JSON reader System.Text.Json in .NET Core 3.0. The example code from Microsoft takes a ReadOnlySpan<byte&gt...
Elysha asked 4/3, 2019 at 12:42

7

Solved

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 resource that returns a list of Objects...
Dynah asked 12/2, 2020 at 9:7

4

Solved

Edit: I made an issue at the .Net runtime repo yesterday which was closed to by "layomia" with this message: "Adding extension points like this comes with a performance cost at the l...
Connect asked 12/8, 2020 at 12:48

1

Solved

I would like .net core System.Text.Json to ignore the single quote character when escaping characters for serialization but I just can't get it to work: var encoderSettings = new TextEncoderSetting...
Berriman asked 13/10, 2022 at 15:28

3

Solved

I have tried use camelCase insentive on .NET 6 for deseralize content from API I configured like this in Startup.cs, but it is not working .AddControllers() .AddJsonOptions(options => { opti...
Nasopharynx asked 27/4, 2022 at 19:1

2

Solved

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: public enum Example { Trick, Treat...
Myrticemyrtie asked 26/11, 2019 at 22:0

2

A web service is sending me a JSON string. It contains a valid JSON string, but it is poorly formatted. Is there a way I can format it to better display it on the screen? I was hoping to appl...
Frau asked 19/9, 2022 at 18:1

3

Using Newtonsoft we had a custom resolver for ignoring empty collections. Is there any equivalent configuration for the new system.text.json in .Net core 3.1
Univalent asked 13/1, 2020 at 16:37

5

Solved

I am working with System.Text.Json in my project as I am processing large files so also decided to use it for processing GraphQL responses. Due to the nature of GraphQL sometimes I get highly nest...
Brierwood asked 2/5, 2020 at 3:5

© 2022 - 2024 — McMap. All rights reserved.