Skip to main content
Filter by
Sorted by
Tagged with
Advice
0 votes
2 replies
66 views

I'm trying to do a polymorphic deserialization using System.Text.Json in net-8.0. Here is my schema. [JsonPolymorphic(TypeDiscriminatorPropertyName = "type")] [JsonDerivedType(typeof(Manager)...
fingers10's user avatar
  • 8,449
-3 votes
3 answers
157 views

I am trying to deserialize a JSON string in C#: JsonObject json = JsonSerializer.Deserialize<JsonObject> ("{\"columnsperrow\":\"1\",\"columnwidths\":[400.0]...
SPlatten's user avatar
  • 5,861
2 votes
1 answer
73 views

I have a record with a bool property that has default value = true: private record MyRecord() { public bool BoolProperty { get; init; } = true; } I want to ignore the "BoolProperty":...
Theodor Zoulias's user avatar
0 votes
2 answers
108 views

Use case: I want to write a JsonConverter for a generic type like this, but I cannot apply it to the type itself: public class EditingModelConverter<T> : JsonConverter<EditingModel<T>&...
Luke Vo's user avatar
  • 21.6k
6 votes
1 answer
295 views

We are having some issues deserialising classes with Quaternion properties. We are seeing very odd behaviour. The Quaternions deserialise correctly (we can do a custom JsonConverter to confirm the ...
Iain Stanford's user avatar
1 vote
0 answers
69 views

We have a class as shown below: public class KeyVal<Key, Val> { public Key Id { get; set; } public Val Text { get; set; } public KeyVal() { } public KeyVal(Key key, Val ...
user2981411's user avatar
1 vote
1 answer
101 views

Consider these model classes: [JsonPolymorphic(TypeDiscriminatorPropertyName = "$type")] [JsonDerivedType(typeof(A), typeDiscriminator: nameof(A))] [JsonDerivedType(typeof(B), ...
aepot's user avatar
  • 4,864
1 vote
1 answer
236 views

I'm currently using the following code to set up a System.Text.Json JsonSerializerOptions object that alphabetizes properties upon serialization: public static readonly JsonSerializerOptions ...
Chaosed0's user avatar
  • 981
0 votes
0 answers
57 views

Background I have an ASP.NET Core 9 Web API project with [nullable reference types] enabled (<Nullable>enable</Nullable>). In my request DTOs, I declare certain properties as non‑nullable, ...
Tom's user avatar
  • 497
0 votes
0 answers
70 views

I have a basic ASP.NET Web API project. When I send a request, the serialization is done using System.Text.Json. However, when I send a non-valid json, for example text instead of number, it returns a ...
pietro's user avatar
  • 221
2 votes
0 answers
49 views

I am duplicating this question, except applying it to System.Text.Json: How do you limit indentation depth when serializing with Newtonsoft.Json. When serializing an object using System.Text.Json, is ...
Frank Schwieterman's user avatar
0 votes
1 answer
151 views

I am trying to use System.Text.Json library for performance improvement. When I am trying to convert it, System.Text.Json is not able to deserialize the object but Newtonsoft.Json able to do so. How ...
hasan.in's user avatar
  • 733
-5 votes
1 answer
150 views

I have a System.Text.JsonElement with about 100 elements inside. I know of EnumerateArray(), but is there a way to do this backwards, meaning: Start at the last element of the list and enumerate until ...
swrk's user avatar
  • 23
1 vote
1 answer
178 views

I'm implementing a custom JsonConverter that handles nullable types. Specifically, it turns empty strings and empty arrays into null. I've managed to piece together this: (with help from here) public ...
dave's user avatar
  • 61
2 votes
3 answers
162 views

I want to create a JsonSerializable class, that I can inherit from. See this code: using System; using System.Text.Json; using System.Text.Json.Serialization; public interface IJson { string ...
Bart Friederichs's user avatar
0 votes
1 answer
89 views

I have built a C# library to make queries on Salesforce using Web Calls. This is an example of implementation: var myQuery = new SalesForceQueryBuilder<MyCoustomUnicornEntity>() ...
FrankOfTheScience's user avatar
0 votes
1 answer
70 views

I'm wanting to only expose a list as ReadOnly but it's, but while trying to accomodate that for Deserialization, it's not currently working. Firstly, to confirm Serialization: { "StartTime"...
MrGreggles's user avatar
  • 6,195
1 vote
1 answer
91 views

I have the following class: public class DeviceInfo { public string? ip { get; set; } public string? deviceKey { get; set; } public long time { get; set; } public string? version { get;...
jstuardo's user avatar
  • 4,497
1 vote
1 answer
1k views

I am getting the following exception when I am trying to serialize a double that has the value NaN, via JsonConverter The exception is: System.ArgumentException: '.NET number values such as positive ...
Liviu Sosu's user avatar
  • 1,599
4 votes
2 answers
491 views

For example, I have a class that derives from ObservableValidator and my resulting serialization then includes HasErrors. I want to only include my derived class's properties and don't have access to ...
azulBonnet's user avatar
1 vote
1 answer
265 views

I am getting an exception: > System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.InvalidOperationException: TypeInfoResolver '...
Ricardo Peres's user avatar
0 votes
1 answer
54 views

I'm trying to serialise and deserialise a servicebus event class, my event inherits from an abstract base with a generic parameter for the payload, and my base class implements an interface. No matter ...
Malekai's user avatar
  • 45
0 votes
1 answer
77 views

Is is possible to return a nullable int with GetFromJsonAsync? I'm getting a System.Text.Json.JsonException error: The input does not contain any JSON tokens I have a simple API endpoint that ...
GH DevOps's user avatar
  • 512
0 votes
0 answers
132 views

I have classes with polymorphism active e.g. [JsonDerivedType(typeof(DerivedClass1), "derivedClass1")] [JsonDerivedType(typeof(Foo), "foo")] public abstract class BaseClass { } ...
Rand Random's user avatar
  • 7,477
0 votes
0 answers
48 views

I have a class public class Record { public string Name { get; set; } // Flat owner public int Size { get; set; } // Flat size public int Enterance { get; set; } /...
Jayne's user avatar
  • 37

1
2 3 4 5
26