Open hakunagndoro opened 5 years ago
It looks like it is not identifying the Commodity
as a ResourceObject.
The default check to determine if its a resource object looks specifically for an Id
property not taking into consideration the [JsonProperty]
. As commodity does not have an Id
property (only a CommodityId
field) it is doing regular json deserialization on it
This is not the expected behaviour and I believe this is a legitimate bug and will attempt to get a fix for this issue
In the meantime you could rename CommodityId
to Id
. Or alternatively extend ResourceObjectConverter
and override CanConvert
to add custom logic to identify the attribute, this extended converter can be passed to the JsonApiSerializerSettings
constructor
I can confirm renaming CommodityId
to Id
resolved my issue.
Thank you @alex-davies.
I am not able to retrieve the attributes in the jsonapi response data object using the JsonApiSerializer. I am able to retrieve only the Id and and the type properties. I am using the DocumentRoot class. My model looks like this:
This is how I am trying to retrieve the attributes:
As you can see from my json response, and the attributes not being set with the correct values from the response. Where am I going wrong?
Response
The incorrect output, only showing the Id and Type set correctly.