将锯齿状/多维数组传递给Web API方法 [英] Pass jagged/multidimensional array to web api method

查看:85
本文介绍了将锯齿状/多维数组传递给Web API方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以将锯齿状数组传递给Web API方法?例如:

Is it possible to pass a jagged array to a web API method? For example:

public IEnumerable<Object> Get([FromUri]int[][] jaggedArray)

如何在我的Web请求中传递 jaggedArray 的值?该参数不一定必须是 [FromUri]

How would I be able to to pass a value for jaggedArray in my web request? The parameter doesn't necessarily have to be [FromUri]

推荐答案

我设法弄清楚了.可以使用以下格式传递参数:

I managed to figure it out. The parameter can be passed using the following format:

http://www.example.com/api/endPoint?jaggedArray[0][]=406&jaggedArray[0][]=404&jaggedArray[1][]=405&jaggedArray[1][]=407

这将导致包含两个数组的锯齿状数组,每个数组都有两个数字(第一个为406和404,第二个为405和407).

This causes a jagged array containing two arrays, each with two numbers (406 and 404 for the first, then 405 and 407 for the second,) to be received.

这篇关于将锯齿状/多维数组传递给Web API方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆