AsInt64
property AsInt64: Int64 read write;
Example
procedure ScriptEvent(var Value: variant);
var
Text: TJSONString;
Item: TJSONValue;
begin
Text := TJSONString.Create;
try
Item := Text;
Item.AsString := '9223372036854775807';
Value := Item.AsInt64;
finally
Text.Free;
end;
end;
Usage
AsInt64 converts Boolean, String or numeric JSON values to signed 64-bit integers and writes decimal text.
Additional Technical Info
The reader returns 0 when IsNull is true. A non-null Boolean maps to 1 or 0. A String or jsNumber passes its raw virtual text to Delphi StrToInt64; malformed text and signed 64-bit overflow raise EConvertError. Arrays, objects and other value kinds raise Deltics EJSONError before conversion.
This is not a strict JSON-number parser. The selected Delphi routine also supports its documented integer notations, and numeric text from TJSONDouble is first generated by locale-sensitive FloatToStr. A Double with a decimal/exponent form generally fails even when mathematically integral; a formatted whole value can succeed. Use the actual value contract rather than relying only on ValueType = jsNumber.
Writing converts the signed value with IntToStr and passes that decimal text directly to the concrete virtual setter. TJSONInteger can store the full range natively; TJSONDouble parses it as binary64 and can lose exactness outside 53-bit integer precision; TJSONString stores the characters. Boolean and incompatible container targets can raise or enter their documented replacement paths.
Null and integer zero both read as 0; check IsNull when they differ. Conversion is synchronous and constant-space. The integer routines are locale-independent for decimal output.
External references
- Embarcadero
StrToInt64 - Embarcadero
IntToStr - Free Pascal
StrToInt64- compatibility reference; accepted non-decimal notation can differ from Delphi. - Free Pascal
IntToStr- compatible decimal formatting context.