diff --git a/src/Umbraco.Web/WebApi/JsonCamelCaseFormatter.cs b/src/Umbraco.Web/WebApi/JsonCamelCaseFormatter.cs new file mode 100644 index 0000000000..67adea187f --- /dev/null +++ b/src/Umbraco.Web/WebApi/JsonCamelCaseFormatter.cs @@ -0,0 +1,17 @@ +using System; +using System.Web.Http.Controllers; +using Newtonsoft.Json.Serialization; + +namespace Umbraco.Web.WebApi +{ + /// + /// Applying this attribute to any webapi controller will ensure that it only contains one json formatter compatible with the angular json vulnerability prevention. + /// + public class JsonCamelCaseFormatter : Attribute, IControllerConfiguration + { + public void Initialize(HttpControllerSettings controllerSettings, HttpControllerDescriptor controllerDescriptor) + { + controllerSettings.Formatters.JsonFormatter.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver(); + } + } +} \ No newline at end of file