Pass jagged/multidimensional array to web api method

蓝咒 提交于 2019-12-11 19:56:16

问题


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

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

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]


回答1:


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

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.



来源:https://stackoverflow.com/questions/21443463/pass-jagged-multidimensional-array-to-web-api-method

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!