"For developers", "Server scripts", "Functions description", "JSON", "JSONArraySetLength".
Create JSON array of the specified size and fill it with zeros. The numeration of the array elements begins from zero. JSON array can be filled with elements of any type in any order.
function JSONArraySetLength(var sJSON: string; iLength: integer): integer;
Parameter |
Type |
Value |
---|---|---|
var sJSON |
string |
JSON object as a text string; |
iLength |
integer |
size of the array you want to create. |
0 |
all ok; the array is created and placed into sJSON variable; |
-1 |
number of array elements must be more than zero; zero array created. |
const
SIZE = 9;
var
sJSON: string;
i: integer;
begin
JSONArraySetLength(sJSON, SIZE);
for i := 0 to SIZE do
JSONArraySetInteger(sJSON, i, random(100));
mLogScript(sJSON, '');
end.
[15:35:10] (Log "JSONArraySetLenght"): [78,14,53,13,5,94,52,51,43]
[15:35:10] (Run "JSONArraySetLenght"): Script operation time: 9 ms
[15:35:10] (Run "JSONArraySetLenght"): Script done successfully.