1

Struggling to find how set the serialiser settings in .Net 5 Azure Functions

static Task Main(string[] args)
        {
            var host = new HostBuilder()
                .ConfigureAppConfiguration(configurationBuilder =>
                {
                    configurationBuilder.AddCommandLine(args);
                    
             
                })
                .ConfigureFunctionsWorkerDefaults((hostBuilderContext, workerApplicationBuilder) =>
                {
                    workerApplicationBuilder.UseFunctionExecutionMiddleware();
      


                })
                .ConfigureServices(services =>
                {
                    
                    
                
                })
                .Build();

            return host.RunAsync();
        }

does anyone have an example?

Thanks

0

1 Answer 1

2

Please try the code below:

    static async Task Main()
    {
        var host = new HostBuilder()
            .ConfigureFunctionsWorkerDefaults(builder => {
               
                //use this code for json settings
                builder.Services.AddMvcCore()
                .AddNewtonsoftJson(option =>
                {
                    option.SerializerSettings.Converters.Add(xxx);
                });
            })
            .ConfigureServices(services =>
            {
                
            })
            .Build();

        await host.RunAsync();
    }

Note that the package Microsoft.AspNetCore.Mvc.NewtonsoftJson should be installed.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.