Q:

how to use Json() function in .net core web?

I find that there is a function :Json() in the .net core webapi it is awesome but in the .net core web there is not here.
how can I use it in the .net core web?
like : return Json(list)?

A:

You can return JsonResult , which is intended to return JSON-formatted data :
public JsonResult JsonActionResult()
{
    var data = new { Name = "Alex", LastName = "DeLarge" };

    return Json(data);
}

The Json(object data) function will create Microsoft.AspNetCore.Mvc.JsonResult that serializes the specified data to JSON format for the response.You can click here for more details about Asp.Net Core Action Results .
If you are using Razor pages , you can directly return JsonResult.

