MyChat Scripts Engine: JSONArraySetInteger, change an integer in a JSON array
Changing a specified integer of a JSON array by index. The index begins from 0.
Syntax
function JSONArraySetInteger(var sJSON: string; iIdx, iValue: integer): integer;
Parameters and return values
Parameter |
Type |
Value |
var sJSON |
string |
JSON object as a text string; |
iIdx |
integer |
index of the required array element; |
iValue |
integer |
the contents of the array element. |
Function result
-1 |
JSON parsing error; |
-2 |
invalid index or type of the array element; |
0 |
function done successfully. |
Example
var
JSONArr: string;
i: integer;
begin
JSONArr := '[]';
for i := 0 to 9 do JSONArraySetInteger(JSONArr, i, random(100));
mLogScript(JSONArr, '');
end.
Script function result
[13:50:47] (Log "JSONArraySetInteger"): [79,85,36,89,42,96,58,24,93,69]
[13:50:47] (Run "JSONArraySetInteger"): Script operation time: 2 ms
[13:50:47] (Run "JSONArraySetInteger"): Script done successfully.
See also
Created with the Personal Edition of HelpNDoc: Effortlessly Create High-Quality Help Documentation with a Help Authoring Tool