提交JSON修改数据

提交JSON修改数据

设计目标:

1)可以一次性提交多个表的修改数据

2)跨语言、跨平台

{
    "deltas":
    [
        {
            "table": "tunit",
            "rows":
            [
                {"action": "modify", "original": {"unitid":"11","unitname":"个"}, "current": {"unitname":"中"}},
                {"action": "delete", "original": {"unitid":"66","unitname":"国"}},
                {"action": "insert", "current":{"unitid":"13","unitname":"人"}}
            ]
        }
        ......
    ]
}

解析JSON得到SQL语句: 

procedure TForm1.Button5Click(Sender: TObject);
begin
  var json: string := '{"table": "tunit","rows":[{"action": "modify", "original": {"unitid":"11","unitname":"个"},'
  +'"current": {"unitid":"11","unitname":"中"}},{"action": "delete", "original": {"unitid":"66","unitname":"国"}},'
  +'{"action": "insert", "current":{"unitid":"13","unitname":"人"}}]}';
  var serial: TynJsonCross := TynJsonCross.Create;
  try
    Memo1.Text := serial.JsonToSql(json);
  finally
    serial.DisposeOf;
  end;
end;

  

 

  

  

  

  

  

  

posted @ 2019-04-02 09:47  delphi中间件  阅读(1017)  评论(0编辑  收藏  举报