title: Alternatives to JsonOutputFormatter in ASP.NET Core 3.1 at Controller Level
body: <p>I have a custom filter attribute adapted from <a href="https://stackoverflow.com/a/56127866/1845714">this answer</a> currently implemented for .NET Core 2.2 that I would like to adapt to 3.1. It references Newtonsoft.JSON and I would prefer to keep it that way for compatibility reasons. </p>
  
  <p>The code follows:</p>
  
  <pre><code>public class AllPropertiesAttribute : ActionFilterAttribute
  {
      public override void OnActionExecuted(ActionExecutedContext ctx)
      {
          if (!(ctx.Result is ObjectResult objectResult)) return;
  
          var serializer = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Include };
          serializer.Converters.Add(new StringEnumConverter());
  
          var formatter = new JsonOutputFormatter(serializer, 
                          ctx.HttpContext.RequestServices.GetRequiredService&lt;ArrayPool&lt;char&gt;&gt;());
  
          objectResult.Formatters.Add(formatter);
      }
  }
  </code></pre>
  
  <p><code>JsonOutputFormatter</code> is only supported up to .net core 2.2, <a href="https://docs.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.mvc.formatters.jsonoutputformatter?view=aspnetcore-2.2" rel="noreferrer">according to the official documentation</a>; how should I proceed to keep the same behavior under 3.1?</p>