为了账号安全,请及时绑定邮箱和手机立即绑定

API请求如何传递数组参数

API请求如何传递数组参数

API
胡子哥哥 2018-07-24 17:17:44
API请求如何传递数组参数
查看完整描述

1 回答

?
互换的青春

TA贡献1797条经验 获得超6个赞

Changed the Web-API function to receive JObject and then extracted my Complex objects from it. Web-API functions looks as below:
public Int64 objectPOC(JObject jsonWrapper)
{

dynamic jsonValues = jsonWrapper;
JArray jsonInput = jsonValues.input;
JArray jsonInput2 = jsonValues.input2;

List<TMS_STATUS> _Status = jsonInput.ToObject<List<TMS_STATUS>>();
List<TMS_STATUS> _Status2 = jsonInput2.ToObject<List<TMS_STATUS>>();

Int64 retValu = 0;

for (int i = 0; i < _Status.Count; i++)
{
retValu++;
}

return retValu;
}

Ajax Call is as follows:
function Call_Service () {
var input =
{
STATUS: "MY New Status",
CATEGORY: "My Value"
};

var input2 =
{
STATUS: "MY New Status2",
CATEGORY: "My Value2"
};

var input_array = new Array();
input_array[0] = input;
input_array[1] = input2;

alert(input_array[0].STATUS);

$.ajax({
type: "POST",

查看完整回答
反对 回复 2018-08-25
  • 1 回答
  • 0 关注
  • 1942 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信