Your most likely difficultly is where you were already looking, the JsonConstructor
attribute. This indicates to the JSON deserializer which constructor to use to create the class when deserializing.
In your example, you are using the DefaultSerializer
that is implemented using Newtsonsoft.Json
. If I had to make a guess, you may have put the wrong JsonConstructor
attribute. Make sure you are using the attribute from the Newtonsoft.Json
namespace and not the one from System.Text.Json.Serialization
.
The other possibility is some interaction around parameter names versus the actual content of your JSON documents.
On a side note, for new projects that don’t have legacy serialization needs, I generally recommend using the System.Text.Json
serializer rather than Newtonsoft.Json
, as it’s more performant.