Open yurii-pelekh opened 4 years ago
Note: because of the hard dependency on Newtonsoft.Json
, out of the box JsonApiFramework
does not behave as expected on .NET Core 3.0/3.1 (the serialisation format doesn't match as Newtonsoft.Json
attributes are ignored).
A workaround exists:
Microsoft.AspNetCore.Mvc.NewtonsoftJson
services.AddControllers().AddNewtonsoftJson();
instead of just AddControllers()
in Startup
related:
I was testing the Blogging Web Service example from the repo JsonApiFramework.Samples.
The project was originally made for .net core 2.2, but I changed it to 3.1.
I knew I shoudn't have changed it but it was just a test anyway. "Lets try it out and see what happens", I thought.
I was getting weird responses like (below a small piece of a response)
"jsonApiVersion": {
"version": "1.0",
"meta": null
},
"attributes": [
{
"name": "firstName"
},
{
"name": "lastName"
},
{
"name": "twitter"
}
]
And when I added .AddNewtonsoftJson()
to .AddControllers()
, everything worked as expected:
"jsonapi": {
"version": "1.0"
},
"attributes": {
"firstName": "Sina",
"lastName": "Pesantes",
"twitter": "@spesantes"
}
Thanks skolima for your comment above. Maybe this comment will be useful for someone trying to use this library with .net core 3.1.
Until the Newtonsoft.json dependency is in the code I think would be useful throw an exception if the serializer is not configured properly.
We also just hit this in .Net Core 3 😅
I am getting close(ish) to an implementation in #99. It's a heavier lift than it seems, as System.Text.Json
is architecturally very different from Newtonsoft.Json
.
At this point, I'm just working on getting tests to pass. I welcome anyone who wants to give it a look, esp. @scott-mcdonald. 🤞
For your edification @twcrews , please see my comment here discussing how this request should probably be architected and implemented.
Hi Scott It would be perfect to move to the new (de)serialization library. Do you have any plans for that?