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.
I have verified that I am running the latest version of Nancy
I have verified if the problem exist in both DEBUG and RELEASE mode
I have searched open and closed issues to ensure it has not already been reported
Description
I want to use a custom JsonSerializer for Serializing/Deserializing TimeSpan and Dictionary objects. In V.1.4.5 I could override ConfigureApplicationContainer and register my own Serializers inheriting Newtonsoft.Json.JsonSerializer. The same registration in V2.0 seems now to be ignored.
I also registered a new environment.Json Method in Configure in the Bootstrapper. However, this takes JavaScriptConverter as custom serializers.
Furthermore, I saw Bug #2800 , but the Nancy.Json.Serializers NuGet isn't compatible with NetStandard2.0 !
Steps to Reproduce
CustomBootstrapper
public class CustomBootstrapper : DefaultNancyBootstrapper
{
protected override void ConfigureApplicationContainer(TinyIoCContainer container)
{
base.ConfigureApplicationContainer(container);
container.Register<JsonSerializer, CustomNancyJsonSerializer>();
}
}
CustomNancyJsonSerializer
public class CustomNancyJsonSerializer : JsonSerializer
{
public CustomNancyJsonSerializer()
{
MissingMemberHandling = MissingMemberHandling.Ignore;
NullValueHandling = NullValueHandling.Ignore;
DefaultValueHandling = DefaultValueHandling.Include;
DateFormatHandling = DateFormatHandling.IsoDateFormat;
DateTimeZoneHandling = DateTimeZoneHandling.Unspecified;
ContractResolver = new DefaultContractResolver();
Formatting = Formatting.None;
}
}
Startup
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
app.UseOwin(x => x.UseNancy(o => o.Bootstrapper = new CustomBootstrapper()));
}
}
TestModule
public class TestModule : NancyModule
{
public TestModule() : base("/")
{
Get("/", parameters =>
{
return Negotiate.WithModel(new
{
Id = 1,
Date = DateTime.Now,
TimeS = new TimeSpan(1, 10, 20),
NullField = (int?)null
});
});
}
}
Nancy.Serialization.JsonNet is compatible with Nancy if you use the preRelease version 2.0 of Nancy.Serialization.JsonNet as it seems...
Is there no final release?
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Prerequisites
DEBUG
andRELEASE
modeDescription
I want to use a custom JsonSerializer for Serializing/Deserializing TimeSpan and Dictionary objects. In V.1.4.5 I could override ConfigureApplicationContainer and register my own Serializers inheriting Newtonsoft.Json.JsonSerializer. The same registration in V2.0 seems now to be ignored.
I also registered a new environment.Json Method in Configure in the Bootstrapper. However, this takes JavaScriptConverter as custom serializers.
Furthermore, I saw Bug #2800 , but the Nancy.Json.Serializers NuGet isn't compatible with NetStandard2.0 !
Steps to Reproduce
CustomBootstrapper
CustomNancyJsonSerializer
Startup
TestModule
Actual Json
System Configuration
.Net Core 3.0 WebAPI x86
Windows 10 1809
VisualStudio 2019
The text was updated successfully, but these errors were encountered: