解析返回结果数量 - GetResultCount
函数简介
对插件接口的返回值进行解析,统计其中的元素个数。支持以下两类输入:
- JSON 数组(如
["a","b","c"]、[1,2,3]) - 使用英文逗号
,或竖线|分隔的字符串(如"a,b,c"、"a|b|c")
接口名称
GetResultCount
DLL调用
int GetResultCount(string result)
参数定义:
result(字符串): 插件接口的返回值,支持 JSON 数组或以,/|分隔的字符串。
示例:
int c1 = GetResultCount("[1,2,3]"); // 返回 3
int c2 = GetResultCount("a,b,c"); // 返回 3
int c3 = GetResultCount("x|y|z"); // 返回 3
int c4 = GetResultCount(""); // 返回 0
返回值
整型数:
- 返回解析得到的元素个数;无法解析或为空时返回 0。
注意事项
- 当输入为空指针或空字符串时返回 0。
- JSON 需为数组格式(例如
[ ... ]);若不是数组格式将按分隔字符串尝试解析。
