0

Recently we migrated from asp.net to aspnet.core, we've a global setting jsonSettings.NullValueHandling = NullValueHandling.Ignore; in StartUp.cs in our Asp.net core project.

This setting doesn't allow nulls during serialization and de-serialization process, as per our requirement we need to allow nulls during de-serialization but doesn't need to allow nulls during serialization i.e. from api response to front-end. How the NullValueHandling.Ignore could be override only for serialization process.

Please suggest !

dbc
  • 104,963
  • 20
  • 228
  • 340
Sonu
  • 25
  • 8
  • Which version of asp.net-core are you using? In [tag:asp.net-core-3.0] Json.NET has become an optional add-on, see [Where did IMvcBuilder AddJsonOptions go in .Net Core 3.0?](https://stackoverflow.com/a/55666898/3744182), so the answer will be different than in previous versions. – dbc Dec 15 '19 at 16:11
  • See this [answer](https://stackoverflow.com/a/29660550/7775908) – Alexander Dec 15 '19 at 18:20
  • Then does this answer your question? [ASP.Net Core 2.2 - separate serializer settings for input and output](https://stackoverflow.com/q/59107392/3744182). – dbc Dec 15 '19 at 23:03

0 Answers0