Skip to content

ToJSON

将实体变量序列化为JSON字符串。

业务属性

属性含义说明输入限定示例值
enable是否启用该控件,未启用时不编译是否编译选择值启用
name控件返回值命名控件输出值变量名常量json
text与控件关联的文本设计页控件显示常量toJson
param实体变量流程变量#{object}

使用示例

使用LuaScript控件定义一个实体:

lua
local object = { text = "this is a text" }
local object = { text = "this is a text" }
img.png

ToJSON控件返回值命名为json,参数输入#{object}

img_1.png

添加输出控件输出返回值json

img_2.png

使用curl请求接口:

$ curl http://localhost:6636/api/toJSON
$ curl http://localhost:6636/api/toJSON

接口返回:

json
{
    "json": "{\"text\":\"this is a text\"}"
}
{
    "json": "{\"text\":\"this is a text\"}"
}