MyChat Scripts: JSONArraySetDouble, change the fractional number in JSON object
"For developers", "Server scripts", "Functions description", "JSON", "JSONArraySetDouble".
Change the specified fractional numeric element in JSON array by index. The index starts from 0.
Syntax
function JSONArraySetDouble(var sJSON: string; iIdx: integer; iValue: double): integer;
Parameters and return values
Parameter |
Type |
Value |
var sJSON |
string |
JSON object as a text string; |
iIdx |
integer |
index of the array element; |
iValue |
double |
new content of the array element. |
Function result
-1 |
JSON parsing error; |
-2 |
non-existent index of the array element; |
0 |
function done successfully. |
Example
var
sJSON: string;
x: integer;
begin
sJSON := '[empty]';
x := JSONArraySetDouble(sJSON, 0, Now);
case x of
0: mLogScript(sJSON, '');
-1: mLogScript('invalid index', '');
-2: mLogScript('invalid object', '');
end;
end.
Script work result
[15:41:24] (Log "JSONArraySetDouble"): [43746.6537527894]
[15:41:24] (Run "JSONArraySetDouble"): Script operation time: 8 ms
[15:41:24] (Run "JSONArraySetDouble"): Script done successfully.