• FDMEMTABLE将修改后的数据序列为JSON


    FDMEMTABLE将修改后的数据序列为JSON

    procedure TForm1.Button3Click(Sender: TObject);
    var
      memtable: TFDMemTable;
      ms: TStringStream;
    begin
      memtable := FDMemTable2;
      memtable.CachedUpdates := True;
      if memtable.State in dsEditModes then
        memtable.Post;
      if memtable.ChangeCount = 0 then
        Exit;
      memtable.ResourceOptions.StoreItems := [siDelta, siMeta];
      ms := TStringStream.Create('', TEncoding.UTF8);
      try
        memtable.SaveToStream(ms, sfJSON);
        Memo1.Text := ms.DataString;
      finally
        ms.Free;
        memtable.ResourceOptions.StoreItems := [siDelta, siMeta, siData];
      end;
    end;
    

      JSON字符串如下:

    {
    	"FDBS":
    	{"Version":15,
    		"Manager":
    		{"UpdatesRegistry":true,
    			"TableList":
    			[{"class":"Table","Name":"qryOpen","SourceName":"tunit","SourceID":1,"TabID":0,"EnforceConstraints":false,"MinimumCapacity":50,"CheckNotNull":false,
    				"ColumnList":
    				[
    					{"class":"Column","Name":"unitid","SourceName":"unitid","SourceID":1,"DataType":"AnsiString","Size":4,"Searchable":true,
    					 "Base":true,"OInUpdate":true,"OInWhere":true,"OInKey":true,"OriginColName":"unitid","SourcePrecision":4,"SourceSize":4},
    					{"class":"Column","Name":"unitname","SourceName":"unitname","SourceID":2,"DataType":"AnsiString","Size":6,"Searchable":true,
    					 "AllowNull":true,"Base":true,"OAllowNull":true,"OInUpdate":true,"OInWhere":true,"OriginColName":"unitname","SourcePrecision":6,"SourceSize":6}
    				],"ConstraintList":[],"ViewList":[],
    				"RowList":
    				[
    					{"RowID":0,"RowState":"Modified","RowPriorState":"Unchanged","Original":{"unitid":"11","unitname":"个"},"Current":{"unitid":"11","unitname":"国"}},
    					{"RowID":2,"RowState":"Deleted","Original":{"unitid":"66","unitname":"66"}},
    					{"RowID":3,"RowState":"Inserted","Current":{"unitid":"13","unitname":"是"}}
    				]
    			 }
    			],"RelationList":[],"UpdatesJournal":{"SavePoint":3,"Changes":[{"TabID":0,"RowID":2,"ChangeNumber":0},{"TabID":0,"RowID":3,"ChangeNumber":1},{"TabID":0,"RowID":0,"ChangeNumber":2}]}
    		}
    	}
    }
    

      

     不论使用哪种开发语言,修改后的数据只要如此组织成JSON,就可以提交给FIREDAC中间件。 

      

  • 相关阅读:
    Python:Pandas的基本操作和使用
    奇技淫巧:绝佳笔记篇-wolai
    Scala:(五) 类、对象、继承、模式匹配和样例类
    tree2List
    java mybatis多层collection嵌套查询
    linux 查看目录下各个文件的大小
    Redisson使用手册
    hutool 定时任务 TimedCache
    清理Docker占用的磁盘空间
    java线程池
  • 原文地址:https://www.cnblogs.com/hnxxcxg/p/10630727.html
Copyright © 2020-2023  润新知