MyChat Scripts: function JSONGetFloat, getting a fractional number from JSON object
Get the fractional numeric key from JSON object (real number).
Syntax
function JSONGetFloat(sJSON, sKey: string; var iValue: double): integer;
Parameters and return values
Parameter |
Type |
Value |
sJSON |
string |
JSON object as a text string; |
sKey |
string |
key name; |
iValue |
var double |
key values (if it exists). |
Function result
0 |
no errors; |
1 |
JSON parsing error; |
2 |
key not found. |
Example
const
iUIN = 6;
var
sJSON: string;
dt: double;
begin
sJSON := mGetUserDataAsJSON(iUIN, 'Birthday');
JSONGetFloat(sJSON, 'Birthday', dt);
mLogScript(FormatDateTime('d mmm yyyy', dt), '');
end.
Script work result
[13:01:01] (Log "JSONGetFloat"): Oct 9, 1979
[13:01:01] (Run "JSONGetFloat"): Script operation time: 7 ms
[13:01:01] (Run "JSONGetFloat"): Script done successfully.