最近在处理贯标的JSON数据,为了全部遍历所有的数据。
使用SuperObject.
{
type
BllParam = record
sParamName: string;
sParanAlias: string;
sParamvalue: string;
sparsmvalueAlias: string;
sNode: string;
iParamType: TFieldType; //
end;
arrayBllParam = array of BllParam;
}
function TGBiao.pAnalysisOutput_array(var aprs: arrayBllParam; aOstr: string; aRoot: string): arrayBllParam;
var
jo, iTEMjo: ISuperObject;
N: Integer;
begin
jo := SO(aOstr);
for N := 0 to jo.AsArray.Length - 1 do
begin
jo.AsArray.O[N];
pAnalysisOutput(aprs,jo.AsArray.O[N].AsString,aRoot);
end;
end;
function TGBiao.pAnalysisOutput(var aprs: arrayBllParam; aOstr: string; aRoot: string): arrayBllParam;
var
jo: ISuperObject;
item: TSuperObjectIter;
begin
jo := SO(aOstr);
if ObjectFindFirst(jo, item) then
repeat
if item.val.IsType(stObject) then
pAnalysisOutput(aprs, item.val.AsString, item.key)
else if item.val.IsType(stArray) then
pAnalysisOutput_array(aprs, item.val.AsString, item.key)
else
begin
// WriteLog(FMemo, Format('key: %s; val: %s', [item.key, item.val.AsString]));
GBCODEConver(aprs, aRoot, item.key, item.val.AsString, item.key); --将数据保存到aprs中。
end;
until not ObjectFindNext(item);
ObjectFindClose(item);
end;