如何用postman将一维int数组

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了如何用postman将一维int数组相关的知识,希望对你有一定的参考价值。

Postman如何用post方法发送数组
由于项目的要求,post请求中有多维数组,以前的post都是一维的,在postman中很容易就解决了,但是在请求中怎么写postman的多维数组呢?
在form-data中像下面一样输入:

Key Value
box[] a
box[n1] b
box[n2][] c
box[n2][] d
你就会获得像下面的数组

"box":"0":"a","n1":"b","n2":["c","d"]

使用Postman测试 一个API,有一个输入参数是List,查了半天,终于知道怎么输入了。

原帖子:http://stackoverflow.com/questions/12756688/is-it-possible-to-send-an-array-with-the-postman-chrome-extension

因为不同的postman版本好像输入方法不同,所以挨着试试看下面的方法。

如果要输入一个arrayList,arr=111,222;

方法1  把list元素分个写

参数名   参数值

arr[0]    111

arr[1]      222

If that doesn't work, try not putting indexes in brackets:

my_array[]  value1
my_array[]  value2

Note:

    If you are using the postman packaged app, you can send an array by selecting raw / json(instead of form-data).

    If you are using the postman REST client you have to use the method I described above because passing data as raw (json) won't work. There is a bug in the postman REST client (At least I get the bug when I use 0.8.4.6).

    Just in case someone is asking how to add hashes instead of just array, the idea is still the same, just change the indexes to hash name my_array[hashname] value1

    my_array[] 123, 345, 456 works fine

    my_array[] value will create a array parameter with the values provided, as key => [value].my_array[key] value will create a hash, as key => value.

    方法2 

    Here is my solution:

    use form-data and edit as below:

    Key       Value
    box[]      a
    box[n1]    b
    box[n2][]  c
    box[n2][]  d

    and you will get an array like this:

    "box":"0":"a","n1":"b","n2":["c","d"]
    方法3

参考技术A Postman如何用post方法发送数组
由于项目的要求,post请求中有多维数组,以前的post都是一维的,在postman中很容易就解决了,但是在请求中怎么写postman的多维数组呢?
在form-data中像下面一样输入:

Key Value
box[] a
box[n1] b
box[n2][] c
box[n2][] d
你就会获得像下面的数组

"box":"0":"a","n1":"b","n2":["c","d"]

c++如何用指针指向二维数组

不能用二维指针指向二维数组,指向二维数组的指针最后一维必须是确定的。
int
a[4][4]=1,2,3,4,2,3,4,5,3,4,5,6,4,5,6,7;
int
(*s)[4];
//表明s指向一个n*4的数组
s=a;
还有一种方法是将二维数组看成是一维数组(因为数组在内存中连续存储)
int
a[4][4]=1,2,3,4,2,3,4,5,3,4,5,6,4,5,6,7;
int
*s;
s=&a[0][0];
这样可以用s[x*y]来表示a[x][y];
参考技术A 你是想让这个指针直接指向你静态定义的数组还是指让指针开辟一块新空间让它等于静态数组,这是很不同的。
照楼上说的方法你自然可以很方便得到静态数组的指针。但是注意如果你的这个赋值是要在其他地方使用,即不是在
[2][15]
=
0,
0,
0,
1,
2,
3,
2,
1,
-1,
4,
5,
6,
-1
所在的函数内部使用的话(而且用到指针的大都这种状况)
那么你必须new出一片新空间来,再用原来的静态定义给新空间赋值。
这样保证你所得到的地址是有效的,这些数字还在。
如果你直接在外部使用静态定义的数组的话,地址自然能找到,但是里面其实已经被析构掉了,内容天差地别,你对其操作还会引起非法。
诸多麻烦。。本回答被提问者采纳

以上是关于如何用postman将一维int数组的主要内容,如果未能解决你的问题,请参考以下文章

如何用Postman做接口测试

如何用Postman组装Request并且查看Response的内容

如何用PostMan请求WebApi

如何用Postman测试整套接口?测试流程是什么?

如何用postman做接口测试

如何用postman做接口测试