How can I configure JSON serializer
See original GitHub issueI need to configure JSON serializer below this code doesn’t work
services.Configure<MvcJsonOptions>(jsonOptions =>
{
jsonOptions.SerializerSettings.ContractResolver = new UnixTimeContractResolver
{
NamingStrategy = new CamelCaseNamingStrategy()
};
});
I checked the sourcecode in AbpServiceCollectionExtensions
, I see the code like below
public static IServiceProvider AddAbp<TStartupModule>(this IServiceCollection services, [CanBeNull] Action<AbpBootstrapperOptions> optionsAction = null)
where TStartupModule : AbpModule
{
var abpBootstrapper = AddAbpBootstrapper<TStartupModule>(services, optionsAction);
ConfigureAspNetCore(services, abpBootstrapper.IocManager);
return WindsorRegistrationHelper.CreateServiceProvider(abpBootstrapper.IocManager.IocContainer, services);
}
private static void ConfigureAspNetCore(IServiceCollection services, IIocResolver iocResolver)
{
//....
//Configure JSON serializer
services.Configure<MvcJsonOptions>(jsonOptions =>
{
jsonOptions.SerializerSettings.ContractResolver = new AbpContractResolver
{
NamingStrategy = new CamelCaseNamingStrategy()
};
});
//Configure MVC
//Configure Razor
}
so, I can’t override Configure JSON serializer
in abp 3.3, this issue https://github.com/aspnetboilerplate/aspnetboilerplate/issues/2764 is work, but it doesn’t work now, my version is AbpCore 3.6.1
please help me, thanks
Issue Analytics
- State:
- Created 5 years ago
- Comments:9 (3 by maintainers)
Top Results From Across the Web
How to set json serializer settings in asp.net core 3?
Gets or sets a function that creates default JsonSerializerSettings. Default settings are automatically used by serialization methods on ...
Read more >How to instantiate JsonSerializerOptions with System.Text. ...
Reuse the same instance for every call. This guidance applies to code you write for custom converters and when you call JsonSerializer.Serialize ......
Read more >Serialization Settings
A JsonConverter allows JSON to be manually written during serialization and read during deserialization. This is useful for particularly complex ...
Read more >ASP.NET Core JSON Serialization - Documentation - Telerik
Configure JSON Serialization in ASP.NET Core 2. To maintain the property names casing, locate the ConfigureServices method and update it by adding the...
Read more >Using multiple JSON serialization settings in ASP.NET Core
First, we need a way to specify multiple JSON serialization settings, and access these settings by name. Fortunately, ASP.NET Core got us ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@ismcagdas thank very much,it’s work. 😁
It’s work for me.
services.PostConfigure<MvcNewtonsoftJsonOptions>(options => { options.SerializerSettings.ContractResolver = new MyContractResolver() { NamingStrategy = new CamelCaseNamingStrategy() }; options.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore; });