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

TJsonObject.AddArray#

Adiciona um array filho novo ou anexa um array existente.

Declarações#

function AddArray(const Name: String): TJsonArray;
function AddArray(const Name: String; const Value: TJsonArray): TJsonObject;

Exemplo#

uses
  Odisseia.Json;
var Root: TJsonObject; Child, Attached: TJsonArray;
begin
  Root := TJsonObject.Create;
  Child := Root.AddArray('items');
  Child.AddString('first');
  Attached := TJsonArray.Create;
  Attached.AddInteger(7);
  Root.AddArray('attached', Attached);
  Attached.AddInteger(8);
  WriteLn(IntToStr(Root.GetArray('items').Count));
  WriteLn(IntToStr(Root.GetArray('attached').Count))
end.

Resultado esperado: 1 e 2.

A sobrecarga de dois argumentos retorna o objeto receptor e anexa o container por identidade. Ciclos são rejeitados. Uma chave existente é substituída.