You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jan 24, 2021. It is now read-only.
We want are Nancy modules to ignore null values when returning json objects.
Despite registering a custom JsonSerializer null values aren't ignored. Unfortunatly this solved issue did not help.
Steps to Reproduce
Create a Visual Studio Nancy empty project wieth ASP.host.
Add an element containing this :
usingNancy;usingNancy.TinyIoc;usingNewtonsoft.Json;namespaceNancyEmptyAspNetHost7{/// <summary>/// A custom json serializer to ignore null values./// </summary>publicsealedclassCustomJsonSerializer:JsonSerializer{publicCustomJsonSerializer(){NullValueHandling=NullValueHandling.Ignore;}}/// <summary>/// A boostrapper registering the json serializer on ConfigureApplicationContainer./// </summary>publicclassMyBoostrapper:DefaultNancyBootstrapper{protectedoverridevoidConfigureApplicationContainer(TinyIoCContainercontainer){base.ConfigureApplicationContainer(container);container.Register<JsonSerializer,CustomJsonSerializer>();}}/// <summary>/// A simple class./// </summary>publicclassFoo{publicobjectBar{get;set;}}/// <summary>/// A module./// </summary>publicclassMyModule:NancyModule{publicMyModule(){Get[""]= _ =>{returnResponse.AsJson(newFoo());// expected : {}// actual : {"bar":null}};}}}
F5.
Browser shows {"bar": null}
instead of {}.
I'm pretty much sure I'm missing something simple, and I feel sorry for posting such a trivial issue, but it's starting to be very time consuming. Thanks for the help.
The text was updated successfully, but these errors were encountered:
Description
We want are Nancy modules to ignore null values when returning json objects.
Despite registering a custom JsonSerializer null values aren't ignored. Unfortunatly this solved issue did not help.
Steps to Reproduce
{"bar": null}
{}
.I'm pretty much sure I'm missing something simple, and I feel sorry for posting such a trivial issue, but it's starting to be very time consuming. Thanks for the help.
The text was updated successfully, but these errors were encountered: