主题
解析返回结果数量 - GetResultCount
函数简介
对插件接口的返回值进行解析,统计其中的元素个数。支持以下两类输入:
- JSON 数组(如
["a","b","c"]、[1,2,3]) - 使用英文逗号
,或竖线|分隔的字符串(如"a,b,c"、"a|b|c")
接口名称
GetResultCountDLL调用
int GetResultCount(string result);参数说明
| 参数名 | 类型 | 说明 |
|---|---|---|
| result | 字符串 | 插件接口的返回值,支持 JSON 数组或以 ,/| 分隔的字符串。 |
示例
SDK 调用
cpp
#include "OLAPlugServer.h"
OLAPlugServer ola;
int ret = ola.GetResultCount("value");csharp
using OLAPlug;
var ola = new OLAPlugServer();
int ret = ola.GetResultCount("value");python
from OLAPlugServer import OLAPlugServer
ola = OLAPlugServer()
ret = ola.GetResultCount("value")java
import com.olaplug.OLAPlugServer;
OLAPlugServer ola = new OLAPlugServer();
int ret = ola.GetResultCount("value");cpp
var ola = com("OlaPlug.OlaSoft")
var ret = ola.GetResultCount("value")vbscript
Set ola = CreateObject("OlaPlug.OlaSoft")
ret = ola.GetResultCount("value")text
.局部变量 ola, OLAPlug
ola.创建 ()
ret = ola.GetResultCount(“value”)aardio
import OLAPlugServer;
var ola = OLAPlugServer();
var ret = ola.GetResultCount("value");text
变量 ola <类型 = OLAPlugServer>
ola = 新建 OLAPlugServer
整数 ret = ola.GetResultCount("value")cpp
#include "OLAPlugServer.h"
OLAPlugServer ola;
int32_t ret = ola.GetResultCount("value");原生 DLL 调用
cpp
GetResultCount(instance, "value");csharp
using System.Runtime.InteropServices;
using System.Text;
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern int GetResultCount(string result);
GetResultCount(instance, "value");python
from ctypes import CDLL, c_int, c_int64, create_string_buffer
ola = CDLL("OLAPlug_x64.dll")
ola.CreateCOLAPlugInterFace.restype = c_int64
ola.GetResultCount(instance, "value")返回值
| 返回值 | 说明 |
|---|---|
| (返回值) | 整型数:返回解析得到的元素个数;无法解析或为空时返回 0。 |
注意事项
| 项目 | 说明 |
|---|---|
| 当输入为空指针或空字符串时返回 0 | 当输入为空指针或空字符串时返回 0。 |
| 格式 | JSON 需为数组格式(例如 [ ... ]);若不是数组格式将按分隔字符串尝试解析。 |
