MyChat Scripts Engine: JSONArrayLength, length of a JSON array
Function to get a number of array elements in JSON format.
Syntax
function JSONArrayLength(sJSON: string): integer;
Parameters and return values
Parameter |
Type |
Value |
sJSON |
string |
JSON object as a text string. |
Function result
-1 |
JSON parsing error; |
>=0 |
number of array elements. |
Example
const
JSON = '[17,54,98,34,51]';
begin
mLogScript('JSON Array: ' + JSON, '');
mLogScript(' Length: ' + IntToStr(JSONArrayLength(JSON)), '');
end.
Script work result
[10:37:54] (Log "JSONArrayLength"): JSON Array: [17,54,98,34,51]
[10:37:54] (Log "JSONArrayLength"): Length: 5
[10:37:54] (Run "JSONArrayLength"): Script operation time: 6 ms
[10:37:54] (Run "JSONArrayLength"): Script done successfully.
See also
Created with the Personal Edition of HelpNDoc: Import and export Markdown documents