Description
In previous versions of ASP.NET Core, the overloads for rendering Json were:
public virtual JsonResult Json(object data, JsonSerializerSettings serializerSettings);
public virtual JsonResult Json(object data);
Here, JsonSerializerSettings
is Newtonsoft.Json.JsonSerializerSettings
.
Since decoupling the dependency in 3.0 though, it's now:
public virtual JsonResult Json(object data, object serializerSettings);
public virtual JsonResult Json(object data);
While this makes sense to decouple from Newtonsoft specifically, it makes for a poor user experience. For example, I couldn't readily find what type I'm supposed to be using for the serializerSettings
argument.
Is there harm in adding additional overloads that are specific? For example, the Microsoft.AspNetCore.Mvc.NewtonsoftJson
package could add a:
public static Json(this Controller controller, object data, JsonSerializerSettings serializerSettings);
It'd expose a specific overload for the user to use. The same for System.Text.Json
.
If all of this isn't doable for API compat reasons, at the very least the docs should be updated. The out-of-the-box experience with System.Text.Json
is very confusing and leaves a user lost on what they're supposed to be doing.