-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to ignore properties on model if I'm not using Newtonsoft.Json #2316
Comments
Ref: #2243 |
So if you use them, you are coupled with that particular serialiser. No doubt when #2243 is done, you'd opt to use System.Text.Json and then all your generated model classes will have the appropriate attribute rather than newtonsofts. However Newtonsoft also honours DataContract's i.e If Microsoft did do that, it would be possible for tools like NSwag to generate less serialiser specific code, as models could use data contracts honored by a variety of serialisers. It would also be possible for libraries in the .NET ecosystem that provide serialisable models, to avoid passing a dependency on a particular serialiser onto their consumers. |
How about the attribute BindNeverAttribute from assembly Microsoft.AspNetCore.Mvc.Core? [BindNever] ignores the properties on the model. Give it a try! |
We probably need to set the property to ignored when the System.Text.Json ignore attribute is on the property: |
In ASP.NET Core 3.0, Newtonsoft.Json has been removed from Microsoft.AspNetCore.App, so there's no
Newtonsoft.Json.JsonIgnore
by default anymore. Instead, it uses System.Text.Json by default.How can I ignore properties on model if I'm not using Newtonsoft.Json? Is there any way to config a custom ignore attribute?
The text was updated successfully, but these errors were encountered: