MyChat Scripts Engine: JSONGetDateTime, get date/time from a JSON object
Function to obtain the date/time value of a key from a JSON object.
Syntax
function JSONGetDateTime(sJSON, sKey: string; var dtvalue: double): integer;
Parameters and return values
Parameter |
Type |
Value |
sJSON |
string |
JSON object as a text string; |
sKey |
string |
required key name; |
dtValue |
var double |
key value, if available. |
Function result
0 |
no errors; |
1 |
JSON parsing error; |
2 |
key not found. |
Example
var
s: string;
dt: double;
begin
s := '{"Value" : "17.10.1990.18.36.54"}'; // date/time format: mm.dd.yyyy.hh.nn.ss
// (month, day, year, hours, minutes, seconds)
if JSONGetDateTime(s, 'Value', dt) = 0 then begin
mLogScript(FormatDateTime('mmmm yyyy, date: d, day of the week: dddd', dt), 'Date&Time test');
end;
end.
Script work result
[14:22:17] (Log "test2"): [Date&Time test] October 1990, date: 17, day of the week: Wednesday
See also
Created with the Personal Edition of HelpNDoc: Easily share your documentation with the world through a beautiful website