Odisseia 1.21.56
Português do BrasilManual oficial · 1.21.56
Sobre a tradução em inglês

TJsonValue.AsInteger#

Lê ou substitui o valor como Integer.

Declaração#

property AsInteger: Integer read write;

Exemplo#

uses
  Odisseia.Json;
var Root: TJsonObject; Value: TJsonValue;
begin
  Root := TJsonObject.Create;
  Root.AddInteger('value', 42);
  Value := Root.GetValue('value')!;
  WriteLn(IntToStr(Value.AsInteger));
  Value.AsInteger := 7;
  WriteLn(IntToStr(Root.GetInteger('value', 0)))
end.

Resultado esperado: 42 e 7.

Exige número armazenado como Integer na leitura. A atribuição substitui o escalar e atualiza o container pai.