一:数组创建
var FJson := TQJson.Create;
try
with FJson.AddArray('Arr') do
begin
for i := 0 to 1 do
begin
with add do
begin
Add('User').AsInteger := i;
Add('Name').AsString :='name'+IntToStr(i);
end;
end;
end;
ShowMessage(FJson.AsJson);
finally
FJson.Free;
end;
结果:
二:数组解析
var
FJson,FIJson:TQJson;
i:Integer;
begin
FJson := TQJson.Create;
try
FJson.Parse(Str);//Str即一中组装出来的json串
FIJson := FJson.ItemByName('Arr');
if FIJson <> nil then
for I := 0 to FIJson.Count-1 do
MMO1.Lines.Add(IntToStr(FIJson[i].IntByPath('User',-1))
+'='+FIJson[i].ValueByPath('Name',''))
finally
FJson.Free;
end;
end;
结果:
标签:do,begin,end,记录,QDAC,FJson,Add,FIJson,QJson From: https://www.cnblogs.com/Yang-YaChao/p/16801682.html