lazarus json

delphi中间件發表於2024-06-30
uses fpjson, jsonparser

function jsonArray(json: string): tjsonarray;
begin
  result := getjson(json) as tjsonarray;
end;

function jsonObject(json: string): tjsonobject;
begin
  result := getjson(json) as tjsonobject;
end;  
             
function jsonFromFile(filename: string): tjsonobject;
var
  sl: TStringList;
begin
  sl := TStringList.Create;
  try
    sl.LoadFromFile(filename);
    Result := getjson(sl.Text) as tjsonobject;
  finally
    sl.Free;
  end;
end;      

var jo: tjsonobject;
var ja: tjsonarray; 
jo.add();
jo.get();       
ja := jo.Find('dataset') as tjsonarray;    

相關文章