• JSON序列——保存修改数据2


    JSON序列——保存修改数据2

    procedure TForm1.Button7Click(Sender: TObject);
    begin
      var delta: TynJsonDelta := TynJsonDelta.Create('tunit');
      var delta2: TynJsonDelta := TynJsonDelta.Create('tgoods');
      var deltas: TynJsonDeltas := TynJsonDeltas.Create;
      try
        delta.Insert('{"unitid":"13","unitname":"人"}');
        delta.Delete('{"unitid":"66","unitname":"国"}');
        delta.Update('{"unitid":"11","unitname":"中"}', '{"unitid":"11","unitname":"个"}');
        delta2.Insert('{"goodsid":"123456","goodsname":"咏南中间件"}');
        deltas.Add(delta.Text);
        deltas.Add(delta2.Text);
        Memo1.Text := deltas.Text;
      finally
        delta.Free;
        delta2.Free;
        deltas.Free;
      end;
    end;
    

      生成JSON:

    {
    	"deltas": [
    		{
    			"table": "tunit",
    			"rows": [
    				{
    					"action": "insert",
    					"current": {
    						"unitid": "13",
    						"unitname": "人"
    					}
    				},
    				{
    					"action": "delete",
    					"original": {
    						"unitid": "66",
    						"unitname": "国"
    					}
    				},
    				{
    					"action": "modify",
    					"current": {
    						"unitid": "11",
    						"unitname": "中"
    					},
    					"original": {
    						"unitid": "11",
    						"unitname": "个"
    					}
    				}
    			]
    		},
    		{
    			"table": "tgoods",
    			"rows": [
    				{
    					"action": "insert",
    					"current": {
    						"goodsid": "123456",
    						"goodsname": "咏南中间件"
    					}
    				}
    			]
    		}
    	]
    }
    

      

  • 相关阅读:
    Python+MySQL学习笔记(一)
    MySQL的基本操作
    2016.08.15
    使用vue为image的src动态赋值
    json对象与json字符串的转化
    js三元运算符
    uniapp vue中的短信验证码
    设计模式
    回调函数
    自定义注解
  • 原文地址:https://www.cnblogs.com/hnxxcxg/p/10657080.html
Copyright © 2020-2023  润新知