mormot2 json操作
mormot2 json操作
procedure Tcrud.select; var db: Tdb; pool: Tdbpool; jo: Tdocvariantdata; i: integer; begin jo.init; try try pool := GetDBPool(DBID); db := pool.Lock; for i := 0 to high(sqls) do begin DB.select(sqls[i]); jo.AddItem(_json(DB.qry.tojsonarraystring)); end; ctxt.SetOutJson(jo.ToJson); except on E: Exception do begin ctxt.SetOutJson(error(E.Message)); WriteLog('db.tables.crud.select()' + E.Message); end; end; finally pool.Unlock(db); end; end;
procedure Tcrud.select; var db: Tdb; pool: Tdbpool; jo: variant; i: integer; begin Tdocvariant.NewFast(jo); try try pool := GetDBPool(DBID); db := pool.Lock; for i := 0 to high(sqls) do begin DB.select(sqls[i]); jo.r := _json(DB.qry.tojsonarraystring);//dataset-->json end; ctxt.SetOutJson(variantsavejson(jo)); except on E: Exception do begin ctxt.SetOutJson(error(E.Message)); WriteLog('db.tables.crud.select()' + E.Message); end; end; finally pool.Unlock(db); end; end;
本文来自博客园,作者:{咏南中间件},转载请注明原文链接:https://www.cnblogs.com/hnxxcxg/p/18370309