遍历对象和数值
var
jo,jo_row:TJSONObject;
ja_dataList:TJSONArray;
allSize,currentPage,pagesize,status,i,j:Integer;
begin
if OpenDialog1.Execute() then
begin
with TStringList.Create do
begin
LoadFromFile(OpenDialog1.FileName);
jo := TJSONObject.ParseJSONValue(Text) as TJSONObject;
Free;
end;
status := StrToInt(jo.GetValue('status').Value);
if status = 200 then
begin
allSize := StrToInt(jo.GetValue('allSize').Value);
currentPage := StrToInt(jo.GetValue('currentPage').Value);
pagesize := StrToInt(jo.GetValue('size').Value);
ja_dataList := jo.GetValue('dataList') as TJSONArray;
for I := 0 to ja_dataList.Count -1 do
begin
jo_row := ja_dataList.Items[i] as TJSONObject; //获取数组中的行
for j := 0 to jo_row.count - 1 do //获取TJSONObject对象中的key与value
begin
memo1.lines.add(jo_row.Get(j).JsonString.Value+ ' = ' + jo_row.Get(j).JsonValue.Value);
end;
end;
end;
end;
end;