Skip to content

TableInsert

在数组的指定索引中插入元素

Lua数组的索引下标是从 1 开始的

业务属性

属性含义说明输入限定示例值
enable是否启用该控件,未启用时不编译是否编译选择值启用
text与控件关联的文本设计页控件显示常量TableInsert
input输出参数流程变量#{array}
insertIndex插入索引空则默认插入数组最后常量/流程变量1
insertValue插入值常量/流程变量a

使用示例

输入常量

输入:#{body.array},插入值输入:6

img_7.png

输出控件返回body.arraydata属性为:

json
{
  "array": "#{body.array}"
}
{
  "array": "#{body.array}"
}
img_8.png

使用curl请求接口:

$ curl http://localhost:6636/api/tableInsert -d "{ \"array\": [1,2,3,4,5] }"
$ curl http://localhost:6636/api/tableInsert -d "{ \"array\": [1,2,3,4,5] }"

接口返回:

json
{
    "array": [1,2,3,4,5,6]
}
{
    "array": [1,2,3,4,5,6]
}

输入指定变量

插入索引输入:#{body.index},插入值输入:#{body.value}

img_9.png

使用curl请求接口:

$ curl http://localhost:6636/api/tableInsert -d "{ \"array\": [1,2,3,4,5,6], \"index\": 4, \"value\": 7}"
$ curl http://localhost:6636/api/tableInsert -d "{ \"array\": [1,2,3,4,5,6], \"index\": 4, \"value\": 7}"

接口返回:

json
{
    "array": [1,2,3,7,4,5,6]
}
{
    "array": [1,2,3,7,4,5,6]
}