检查输入是否为空数组或空数组,并保存为空数组,否则复制对象数组
check if input is an empty array or empty array of arrays and save as just empty array otherwise copy the array of objects
检查输入是否为空数组或空数组,并另存为空数组,否则复制对象数组。
感谢任何帮助
{
"response": {
"body": {
"variables": {
"sample": {
"type": "Json",
"value": [
[
[]
]
],
"valueInfo": {}
}
}
}
}
}
我的规格:
[
{
"operation": "shift",
"spec": {
"response": {
"body": {
"variables": {
"sample": {
"value": "."
}
}
}
}
}
}
]
预期输出:
[]
您可以通过连续使用 split 和 join[ 摆脱数组的包装器(方括号) =23=] 在 modify 转换中运行,以测量剩余数组的大小是否为 zero 或 not,然后根据这个结果判断结果如
[
{
"operation": "modify-overwrite-beta",
"spec": {
"response": {
"body": {
"variables": {
"sample": {
"str0": "=toString(@(1,value))",
"str1": "@(1,str0[0])",
"str2": "=split('\[', @(1,str1))",
"str3": "=join('',@(1,str2))",
"str4": "=split('\]', @(1,str3))",
"sz": "=size(@(1,str4))"
}
}
}
}
}
},
{
"operation": "shift",
"spec": {
"response": {
"body": {
"variables": {
"sample": {
"sz": {
"0": { "@(2,str4)": "" },
"*": { "@(2,value)": "" }
}
}
}
}
}
}
}
]
检查输入是否为空数组或空数组,并另存为空数组,否则复制对象数组。 感谢任何帮助
{
"response": {
"body": {
"variables": {
"sample": {
"type": "Json",
"value": [
[
[]
]
],
"valueInfo": {}
}
}
}
}
}
我的规格:
[
{
"operation": "shift",
"spec": {
"response": {
"body": {
"variables": {
"sample": {
"value": "."
}
}
}
}
}
}
]
预期输出:
[]
您可以通过连续使用 split 和 join[ 摆脱数组的包装器(方括号) =23=] 在 modify 转换中运行,以测量剩余数组的大小是否为 zero 或 not,然后根据这个结果判断结果如
[
{
"operation": "modify-overwrite-beta",
"spec": {
"response": {
"body": {
"variables": {
"sample": {
"str0": "=toString(@(1,value))",
"str1": "@(1,str0[0])",
"str2": "=split('\[', @(1,str1))",
"str3": "=join('',@(1,str2))",
"str4": "=split('\]', @(1,str3))",
"sz": "=size(@(1,str4))"
}
}
}
}
}
},
{
"operation": "shift",
"spec": {
"response": {
"body": {
"variables": {
"sample": {
"sz": {
"0": { "@(2,str4)": "" },
"*": { "@(2,value)": "" }
}
}
}
}
}
}
}
]