提交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;
