public static IMvcBuilder ConfigureTextJson(this IMvcBuilder builder, JsonOptions options, ICustomMediaTypeService customMediaTypeService)
        {
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            return(builder.AddJsonOptions(o =>
            {
                o.JsonSerializerOptions.AllowTrailingCommas = options.BeTolerant;
                o.JsonSerializerOptions.PropertyNameCaseInsensitive = options.BeTolerant;
                if (options.BeTolerant)
                {
                    o.JsonSerializerOptions.ReadCommentHandling = JsonCommentHandling.Skip;
                }
                o.JsonSerializerOptions.IgnoreNullValues = options.IgnoreNullValue;
                o.JsonSerializerOptions.PropertyNamingPolicy = options.UseCamelCase ? JsonNamingPolicy.CamelCase : null;
                if (options.EnumAsString)
                {
                    o.JsonSerializerOptions.Converters.Add(new JsonStringEnumConverter());
                }
            }).AddMvcOptions(o =>
            {
                o.AddCustomInputFormatters();
                o.AddCustomOutputFormatters <SystemTextJsonOutputFormatter>(customMediaTypeService);
            }));
        }
        public static IMvcBuilder ConfigureNewtonSoftJson(this IMvcBuilder builder, JsonOptions options, ICustomMediaTypeService customMediaTypeService)
        {
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            return(builder.AddNewtonsoftJson(o =>
            {
                if (options.UseCamelCase)
                {
                    o.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
                }
                if (options.IgnoreNullValue)
                {
                    o.SerializerSettings.NullValueHandling = NullValueHandling.Ignore;
                }
                if (options.EnumAsString)
                {
                    o.SerializerSettings.Converters.Add(new StringEnumConverter());
                }
                if (options.SerializeReferenceLoop)
                {
                    o.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Serialize;
                }
            }).AddMvcOptions(o =>
            {
                o.AddCustomInputFormatters();
                o.AddCustomOutputFormatters <NewtonsoftJsonOutputFormatter>(customMediaTypeService);
            }));
        }