Changing the date/time value of a specified JSON array element by index. The index begins from 0.

 

Syntax

function JSONArraySetDateTime(var sJSON: string; iIdx: integer; dtValue: double): 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;

dtValue

boolean

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, iCount: integer;
  dt: double;
begin
  JSONArr := '[]';
  
    for i := 0 to 2 do
      JSONArraySetDateTime(JSONArr, i, IncSecond(Now, Random(100))) ;
    for i := 0 to 2 do begin
      JSONArrayGetDateTime(JSONArr, i, dt) ;
      
      mLogScript(FormatDateTime('nn:ss', dt), IntToStr(i));
    end;  
end.


Script work result

[14:24:30] (Log "JSONArraySetDateTime"): [0] 24:56

[14:24:30] (Log "JSONArraySetDateTime"): [1] 24:36

[14:24:30] (Log "JSONArraySetDateTime"): [2] 24:52

[14:24:30] (Run "JSONArraySetDateTime"): Script operation result: 6 ms

[14:24:30] (Run "JSONArraySetDateTime"): Script operation time.
 

See also

FormatDateTime

JSONArrayGetDateTime

IncSecond

IntToStr

mLogScript

Random