如何在.net核心控制器中返回Json对象?

我目前正在使用一个使用API​​的简单网站。到目前为止,我只有原始的json数据,我以为可以使用它,直到可以进行api调用为止。如何以最简单的方式返回json数据?

using microsoft.AspNetCore.Mvc;
using microsoft.Extensions.Logging;

namespace LiuOrg.Controllers
{
    [ApiController]
    [Route("[controller]")]
    public class OrganisationController : ControllerBase
    {
       private string Summaries = @"{ 
                'pointInTime': '2019-11-04T09:29:35.9425587Z','organisationViewType': 'Organisation','tree': {
                    'organisationId': 'efc0d74d-82323-2323','canonicalPath': 'LIU','shortName': 'LIU','enabled': true,'fullName': {
                        'en': 'Linköping University','sv': 'Linköpings universitet'
                    },'financialUnit': -1,'organisationType': 'Company','children': [{
                        'organisationId': 'd1340837-2323-32323','canonicalPath': 'LIU/IBL','shortName': 'IBL',`enter code here`
    ....





     [HttpGet]
        public IactionResult Get()
        {

            return Json(new { Summaries });
        }
  }  }
wangmjdp 回答:如何在.net核心控制器中返回Json对象?

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3153660.html

大家都在问