// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using Newtonsoft.Json; using Newtonsoft.Json.Serialization; namespace Microsoft.AspNetCore.Mvc.Formatters { /// /// Helper class which provides . /// public static class JsonSerializerSettingsProvider { private const int DefaultMaxDepth = 32; /// /// Creates default . /// /// Default . public static JsonSerializerSettings CreateSerializerSettings() { return new JsonSerializerSettings { ContractResolver = new DefaultContractResolver { NamingStrategy = new CamelCaseNamingStrategy(), }, MissingMemberHandling = MissingMemberHandling.Ignore, // Limit the object graph we'll consume to a fixed depth. This prevents stackoverflow exceptions // from deserialization errors that might occur from deeply nested objects. MaxDepth = DefaultMaxDepth, // Do not change this setting // Setting this to None prevents Json.NET from loading malicious, unsafe, or security-sensitive types TypeNameHandling = TypeNameHandling.None, }; } } }