Eğer varsa bir .Net Çekirdek WebAPI veya WebSitesi gelişmekte sen newtownsoft.json yüklemenize gerek Yüklü json seri / deserealization gerçekleştirmek için
Denetleyici yönteminizin a döndürdüğünden emin olun JsonResultve return Json(<objectoToSerialize>);bu örnek gibi çağırın
namespace WebApi.Controllers
{
[Produces("application/json")]
[Route("api/Accounts")]
public class AccountsController : Controller
{
[HttpGet]
public JsonResult Get()
{
List<Account> lstAccounts;
lstAccounts = AccountsFacade.GetAll();
return Json(lstAccounts);
}
}
}
NET Framework WebApi veya WebSite geliştiriyorsanız , newtonsoft jsonpaketi indirmek ve yüklemek için NuGet kullanmanız gerekir
"Proje" -> "NuGet paketlerini yönet" -> "" newtonsoft json "araması yapın. ->" yükle "yi tıklayın.
namespace WebApi.Controllers
{
[Produces("application/json")]
[Route("api/Accounts")]
public class AccountsController : Controller
{
[HttpGet]
public JsonResult Get()
{
List<Account> lstAccounts;
lstAccounts = AccountsFacade.GetAll();
return new JsonConvert.SerializeObject(lstAccounts);
}
}
}
Daha fazla ayrıntı burada bulunabilir - https://docs.microsoft.com/en-us/aspnet/core/web-api/advanced/formatting?view=aspnetcore-2.1