asp.net core furion 前端传入json,后端api接入并角析

浪淘沙9个月前后端200
{
  "result": {
    "cover": {
      "title": "标题",
      "img": "https://localhost:5001/UpLoadFiels/pic.png",
      "link": "",
      "url": "ts_nr"
    },
    "list": [
      {
        "title": "标题1",
        "img": "https://localhost:5001/UpLoadFiels/pic.png",
        "link": "",
        "url": "ts_nr"
      },
{
        "title": "标题2",
        "img": "https://localhost:5001/UpLoadFiels/pic.png",
        "link": "",
        "url": "ts_nr"
      }
  ]
  },
  "ts": {
    "rs": "600",
    "tpe": "定时推送",
    "jhsj": "2026-03-04 00:00:00",
    "title": "1",
    "bz": "1"
  }
}
    [NonUnify]
    [Route("Add")]
    [HttpPost]
    public async Task<object> Add([FromBody] dynamic json)
    {

       
       
        var ts = json.ts;
        var rs = ts.rs;

        var result = json.result;
        var cover= result.cover;
        var title = cover.title;
        //数组
        var list = json.result.list;
        var listcount = list.Count;
        var lstr = "";
        foreach (var item in list)
        {
            string title1 = item.title;
            string img1 = item.img;

            lstr+= "标题:" + title1 + ",图片:" + img1 + "\n";
        }
        return lstr;
    }
    #endregion

}
 fetch('/api/tsExt/Add', {
     method: 'POST',
     headers: { 'Content-Type': 'application/json' },
     body: JSON.stringify(finalData)
 })
 .then(res => res.json())
 .then(res => {
     console.log(res);
   
 });


相关文章

asp.net core 获取当前url

  site = $"{Request.Scheme}://{Request.Host}";...

导出excel

@page @model xxtsoft.Web.Entry.Pages.test2Model @{ } <form method="post"&...

当对象为空时

 autoClearinitialContent:  @(Model.Article_Content.article?.Contains("一键复制Word中的...

asp.net core sqlsugar timestamp 防sql注入方法

 string sql= "insert into ts (title,dx,zt,tsnr,tpe,jhsj,bz,guid)&...

JNTemplate 模板标签读取dt数据

一、模板标签using JinianNet.JNTemplate; private readonly SqlSugar.ISqlSugarClient _db;...

asp.net core razor 使用ClosedXML.Excel 导出表格

            using var workbook...

发表评论    

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。