Open x3igh7 opened 5 months ago
Newtonsoft.Json treats $type
and some other json property names starting with "$" as metadata keywords by default and not as ordinary property names, unless you deactivate the handling of metadata properties by configuring the MetadataPropertyHandling setting as MetadataPropertyHandling.Ignore
.
(The name "Ignore" for this setting is a bit misleading, as property names like $type
are not ignored. Rather, the handling of metadata properties is being disabled, turning metadata keywords like $type
into ordinary json property names.)
I swear this was working properly at one point
I guess in the past you did set MetadataPropertyHandling.Ignore
, but forgot to set it now...
Newtonsoft.Json treats
$type
and some other json property names starting with "$" as metadata keywords by default and not as ordinary property names, unless you deactivate the handling of metadata properties by configuring the MetadataPropertyHandling setting asMetadataPropertyHandling.Ignore
.(The name "Ignore" for this setting is a bit misleading, as property names like
$type
are not ignored. Rather, the handling of metadata properties is being disabled, turning metadata keywords like$type
into ordinary json property names.)I swear this was working properly at one point
I guess in the past you did set
MetadataPropertyHandling.Ignore
, but forgot to set it now...
Thanks for the suggestion - I will give it a try.
Source/destination types
Source/destination JSON
Expected behavior
Expected the Type property value with [JsonProperty(PropertyName = "$type")] be properly set.
Actual behavior
Type property is null.
Steps to reproduce
I swear this was working properly at one point, but it's simply failing now. I have a few other properties that I've mapped with
JsonProperty
in the project and those do work correctly, although they do not have$
in the name. I'm on .net6 still.