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

浪淘沙7个月前后端151
{
  "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);
   
 });


相关文章

点击按钮,禁用提示,加导出word

@page @model xxtsoft.Web.Entry.Pages.sysadmins.kh.kh_outModel @{     Lay...

JNTemplate 模板标签读取dt数据

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

asp.net core furion 返回错误信息

asp.net core furion 返回错误信息

  if (string.IsNullOrEmpty(jd) || string.IsNullOrEmpty(wd))   {...

asp.net core post

<form class="layui-form layui-form-pane" action="" method...

取消 "将 null 文本或可能的 null 值转换为不可为 null 类型。 "提示

在 .csproj 文件中添加或修改:<PropertyGroup>  <Nullable>disable</Nullable></Pro...

asp.net core HttpClient 返回值

  public async Task<IActionResult> OnPostDown()   {  ...

发表评论    

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