webapi接收json字符串

前端访问webapi


<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>首页-测试</title>
</head>
<body>
    <div id="publish_article_whl_content">
  </div>
    <div>
        <input  type="text"  id="account"  />
        <input type="button" value="发送数据" id="btnSend" />
    </div>

    <script src="jquery-1.11.3.min.js"></script>
    <script>
        $("#btnSend").click(function () {
            $.ajax({             
                url: "http://localhost:8079/performance_api/Appoint/AddAppointList",
                type: "post",
				contentType:"application/x-www-form-urlencoded",
                headers: {
                 "Authorization":"Bearer I9R85qjqxQqKV/u32pW1+lEPcTTk8/TG6gvVSU6keXfJPA62bHru/XzCpVgtNVacXBL89oIFLyht3116sthTeQO5GcCnKmm+wie9fJ8v2WeXlSVzS+RfR1oUW8lOQOuC05xYrwCk5wEe4/zKQEntdKnzs5QDiY7egaH4que3YPuhesk1Mj9dXcgY0GHrVO71ogNSBu4DugUQNI9CUXSem5okLPAeMdZFps/CdI/0tRBUqnSvOKUklvh4jSu2Ny0V6kpC4FktZ9E6s6lamreCepdEvmHAT9cwqSUBh8fl1vBcgvImbG+kAVN8upjcN5Z76RaVfwJMHeF9gOR7J9fnZPwwmrvJ1xXKoAgQbWY7TXI7o5ddN0qVDz/Mtk20L9m/ZH2FXxpvKwuaxvdVEiPiurm59U6+fTF0vdvzgrkYbBJM/2TvLeNjOvLOG32tzpn/HC29MYK6ZjzjnFJUDxfjpxGZR7LGsiq3UYLRrh8jqQU="
                }, 
               data: {
                   json:"[{\"One_level\":1,\"Order_month\":\"2020-12\",\"Reward_money\":23000,\"Form_name\":\"绩效奖励\",\"Form_main_id\":\"00323ee91954439da14bb6445a1ea86d\",\"Department_name\":\"中书省\",\"Department_id\":\"5cefead5ab8e4a02a32b95b3f5b8a7e3\",\"Data_type\":2}]"
               },
                success: function (d) {
                    console.log(d);
                }
            });
        });
 
    </script>
</body>
</html>

C#后台接收

[HttpPost]
public async Task<IHttpActionResult> AddAppointList(JsonInput json)
{
	List<Appoint_form> list = null;
	if (!string.IsNullOrWhiteSpace(json.Json))
	{
		list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Appoint_form>>(json.Json);
	}
	Result result = await appoint.AddAppoint_formListAsync(list, CurrentLoginUser);
	return Json(result);
}


 /// <summary>
 /// 接收json参数
 /// </summary>
 public struct JsonInput
 {
     public string Json { get; set; }
 }
  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

王焜棟琦

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值