好幾次想取json的節點名稱,今天搞定了。
procedure GetJsonNames(o: ISuperObject; Strs: TStrings); var ite: TSuperAvlIterator; obj: TSuperAvlEntry; begin ite := TSuperAvlIterator.Create(o.AsObject); try ite.First; obj := ite.GetIter; while obj <> nil do begin strs.Add(obj.Name); ite.Next; obj := ite.GetIter; end; finally ite.Free; end; end; procedure TForm5.Button12Click(Sender: TObject); var o: ISuperObject; Strs: TStrings; begin Strs := TStringList.Create; o := so('{"item1":1,"item2":2,"item3":3}'); GetJsonNames(o, Strs); ShowMessage(Strs.Text); FreeAndNil(Strs); end;