Delphi Json之树遍历

procedure TForm1.VisitDirJsonTree(const AJsonObj: ISuperObject);
var
  i: Integer;
  oItem: TSuperAvlEntry;
begin
  for oItem in AJsonObj.AsObject do
  begin
    if oItem.Value.DataType = stObject then
      VisitDirJsonTree(oItem.Value)
    else if oItem.Value.DataType = stArray then
    begin
      for i := 0 to oItem.Value.AsArray.Length - 1 do
        if oItem.Value.AsArray[i].DataType = stObject then
          VisitDirJsonTree(oItem.Value.AsArray[i]);
    end
    else
      mmo1.Lines.Add(Format('%s : %s', [oItem.Name, oItem.Value.AsString]));
  end;
end;

  

原文地址:https://www.cnblogs.com/laoxia/p/8533768.html