一個很大的json格式資料檔案,欄位很多,實在是懶得組織代碼了,那位同學有通用的代碼,能不能分享一下,萬分感謝。
對了,我使用SuperObject編譯不過去,會出錯。
10.3.1版本。
uj5u.com熱心網友回復:
系統自己就有JSON決議。uj5u.com熱心網友回復:

哦,你是“懶得組織代碼”,給錢,有人幫你組織。
uj5u.com熱心網友回復:
好吧,真沒想到,excel2019竟然支持json格式的匯入,哈uj5u.com熱心網友回復:
網上找了一個通用代碼,有效果,但是會漏陣列前的資料,需要的可以自己修改一下,哈uses
SysUtils,
DBXJSON;
type
TProcessJSONString = TProc<TJSONString>;
procedure DoJSONObject(o: TJSONObject; Process: TProcessJSONString); forward;
procedure DoJSONArray(o: TJSONArray; Process: TProcessJSONString);
var i: integer;
v: TJSONValue;
begin
for i := 0 to o.Size - 1 do begin
v := o.Get(i);
if v is TJSONObject then
DoJSONObject(v as TJSONObject, Process);
end;
end;
procedure DoJSONObject(o: TJSONObject; Process: TProcessJSONString);
var i: integer;
p: TJSONPair;
begin
for i := 0 to o.Size - 1 do begin
p := o.Get(i);
Process(p.JsonString);
if p.JsonValue is TJSONObject then
DoJSONObject(p.JsonValue as TJSONObject, Process)
else if p.JsonValue is TJSONArray then
DoJSONArray(p.JsonValue as TJSONArray, Process)
else if p.JsonValue is TJSONString then
Process(p.JsonValue as TJSONString);
end;
end;
var o: TJSONObject;
begin
o := TJSONObject.ParseJSONValue('{"data":{"results":[{"Branch":"ACCT590003"}]}}') as TJSONObject;
try
DoJSONObject(o,
procedure (o: TJSONString)
begin
WriteLn(o.ToString);
end
);
finally
o.Free;
end;
ReadLn;
end.
uj5u.com熱心網友回復:
雖然我用不上,還是得支持一下的。轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/9565.html
標籤:VCL組件開發及應用
上一篇:FastReprot 二維碼
