咏南中间件JSON序列类
1)支持跨平台、跨语言
2)支持主从表数据序列、还原,支持任意数量的表
主从表数据序列为JSON字符串样式:
{ "rows": [ { "FDBS": { "Version": 15, "Manager": { "UpdatesRegistry": true, "TableList": [ { "class": "Table", "Name": "qryOpen", "SourceName": "tgoods", "SourceID": 1, "TabID": 0, "EnforceConstraints": false, "MinimumCapacity": 50, "CheckReadOnly": false, "ColumnList": [ { "class": "Column", "Name": "goodsid", "SourceName": "goodsid", "SourceID": 1, "DataType": "AnsiString", "Size": 8, "Searchable": true, "Base": true, "OInUpdate": true, "OInWhere": true, "OInKey": true, "OriginColName": "goodsid", "SourcePrecision": 8, "SourceSize": 8 }, { "class": "Column", "Name": "barcode", "SourceName": "barcode", "SourceID": 2, "DataType": "AnsiString", "Size": 18, "Searchable": true, "AllowNull": true, "Base": true, "OAllowNull": true, "OInUpdate": true, "OInWhere": true, "OriginColName": "barcode", "SourcePrecision": 18, "SourceSize": 18 }, { "class": "Column", "Name": "goodsname", "SourceName": "goodsname", "SourceID": 3, "DataType": "AnsiString", "Size": 50, "Searchable": true, "Base": true, "OInUpdate": true, "OInWhere": true, "OriginColName": "goodsname", "SourcePrecision": 50, "SourceSize": 50 }, { "class": "Column", "Name": "pyjm", "SourceName": "pyjm", "SourceID": 4, "DataType": "AnsiString", "Size": 50, "Searchable": true, "AllowNull": true, "Base": true, "OAllowNull": true, "OInUpdate": true, "OInWhere": true, "OriginColName": "pyjm", "SourcePrecision": 50, "SourceSize": 50 }, { "class": "Column", "Name": "gg", "SourceName": "gg", "SourceID": 5, "DataType": "AnsiString", "Size": 30, "Searchable": true, "AllowNull": true, "Base": true, "OAllowNull": true, "OInUpdate": true, "OInWhere": true, "OriginColName": "gg", "SourcePrecision": 30, "SourceSize": 30 }, { "class": "Column", "Name": "kindid", "SourceName": "kindid", "SourceID": 6, "DataType": "AnsiString", "Size": 8, "Searchable": true, "AllowNull": true, "Base": true, "OAllowNull": true, "OInUpdate": true, "OInWhere": true, "OriginColName": "kindid", "SourcePrecision": 8, "SourceSize": 8 }, { "class": "Column", "Name": "jj", "SourceName": "jj", "SourceID": 7, "DataType": "BCD", "Precision": 18, "Scale": 4, "Searchable": true, "AllowNull": true, "Base": true, "OAllowNull": true, "OInUpdate": true, "OInWhere": true, "OriginColName": "jj", "SourcePrecision": 18, "SourceScale": 4 }, { "class": "Column", "Name": "lsj", "SourceName": "lsj", "SourceID": 8, "DataType": "BCD", "Precision": 18, "Scale": 4, "Searchable": true, "AllowNull": true, "Base": true, "OAllowNull": true, "OInUpdate": true, "OInWhere": true, "OriginColName": "lsj", "SourcePrecision": 18, "SourceScale": 4 }, { "class": "Column", "Name": "kcxx", "SourceName": "kcxx", "SourceID": 9, "DataType": "BCD", "Precision": 18, "Scale": 4, "Searchable": true, "AllowNull": true, "Base": true, "OAllowNull": true, "OInUpdate": true, "OInWhere": true, "OriginColName": "kcxx", "SourcePrecision": 18, "SourceScale": 4 }, { "class": "Column", "Name": "kcsx", "SourceName": "kcsx", "SourceID": 10, "DataType": "BCD", "Precision": 18, "Scale": 4, "Searchable": true, "AllowNull": true, "Base": true, "OAllowNull": true, "OInUpdate": true, "OInWhere": true, "OriginColName": "kcsx", "SourcePrecision": 18, "SourceScale": 4 }, { "class": "Column", "Name": "unitid", "SourceName": "unitid", "SourceID": 11, "DataType": "AnsiString", "Size": 8, "Searchable": true, "AllowNull": true, "Base": true, "OAllowNull": true, "OInUpdate": true, "OInWhere": true, "OriginColName": "unitid", "SourcePrecision": 8, "SourceSize": 8 }, { "class": "Column", "Name": "unitname", "SourceName": "unitname", "SourceID": 12, "DataType": "AnsiString", "Size": 10, "Searchable": true, "AllowNull": true, "Base": true, "OAllowNull": true, "OInUpdate": true, "OInWhere": true, "OriginColName": "unitname", "SourcePrecision": 10, "SourceSize": 10 }, { "class": "Column", "Name": "kindname", "SourceName": "kindname", "SourceID": 13, "DataType": "AnsiString", "Size": 30, "Searchable": true, "AllowNull": true, "Base": true, "OAllowNull": true, "OInUpdate": true, "OInWhere": true, "OriginColName": "kindname", "SourcePrecision": 30, "SourceSize": 30 } ], "ConstraintList": [], "ViewList": [], "RowList": [ { "RowID": 0, "Original": { "goodsid": "100036", "barcode": "100036", "goodsname": "秋冬四件套哦", "pyjm": "", "gg": "", "kindid": "12002", "jj": 100, "lsj": 430, "kcxx": 50, "kcsx": 5, "unitid": "15", "unitname": "箱套", "kindname": "床上用品" } }, { "RowID": 1, "Original": { "goodsid": "100050", "barcode": "100050", "goodsname": "天堂伞", "pyjm": "wrth", "gg": "", "kindid": "1", "jj": 10, "lsj": 0, "kcxx": 0, "kcsx": 0, "unitid": "15", "unitname": "箱套", "kindname": "1111" } }, { "RowID": 2, "Original": { "goodsid": "100054", "barcode": "100054", "goodsname": "我们的 哎", "pyjm": "WMD D7", "gg": "", "kindid": "11002", "jj": 0, "lsj": 0, "kcxx": 0, "kcsx": 0, "unitid": "18", "unitname": "公斤", "kindname": "饮料" } }, { "RowID": 3, "Original": { "goodsid": "100055", "barcode": "100055", "goodsname": "娃哈哈纯净水500ML", "pyjm": "WHHCJS500ML", "kindid": "11001", "jj": 0, "lsj": 0, "kcxx": 0, "kcsx": 0, "unitid": "18", "unitname": "公斤", "kindname": "奶粉" } } ] } ], "RelationList": [], "UpdatesJournal": { "Changes": [] } } } }, { "FDBS": { "Version": 15, "Manager": { "UpdatesRegistry": true, "TableList": [ { "class": "Table", "Name": "qryOpen", "SourceName": "tunit", "SourceID": 1, "TabID": 0, "EnforceConstraints": false, "MinimumCapacity": 50, "CheckReadOnly": 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, "Original": { "unitid": "11", "unitname": "个" } }, { "RowID": 1, "Original": { "unitid": "12", "unitname": "双" } } ] } ], "RelationList": [], "UpdatesJournal": { "Changes": [] } } } } ] }
主从表查询调用代码:
procedure TForm1.btnQueryClick(Sender: TObject); // 主从表 查询 begin var url: TynUrl := TynUrl.Create; var serial: TynJsonSerial := TynJsonSerial.Create; var send: TMemoryStream := TMemoryStream.Create; try url.url := Edit1.Text; url.command := 'query91'; // 命令 url.params.Add('count=2'); // 查询几个表的数据 url.params.Add('accountno=1'); // 帐套号 url.params.Add('sql=select * from tgoods'); // 查询SQL url.params.Add('sql2=select * from tunit'); // 查询SQL2 // Memo1.Text := IdHTTP1.Post(url.text, send); serial.Text := IdHTTP1.Post(url.text, send); serial.ReadFDMemTable(0, FDMemTable1); serial.ReadFDMemTable(1, FDMemTable2); finally serial.DisposeOf; send.DisposeOf; url.DisposeOf; end; end;
主从表提交调用代码:
procedure TForm1.btnPostClick(Sender: TObject); // 主从表 提交 begin var url: TynUrl := TynUrl.Create; var serial: TynJsonSerial := TynJsonSerial.Create; var send: TMemoryStream := TMemoryStream.Create; try url.url := Edit1.Text; url.command := 'save91'; // 命令 url.params.Add('count=2'); // 提交几个表的数据 url.params.Add('accountno=1'); // 帐套号 url.params.Add('tablename=tgoods'); // 表名 url.params.Add('tablename2=tunit'); // 表名2 url.params.Add('delta=' + serial.FDDeltaToJson(FDMemTable1)); // delta url.params.Add('delta2=' + serial.FDDeltaToJson(FDMemTable2)); // delta2 serial.Text := IdHTTP1.Post(url.text, send); if Pos('true', serial.Text) > 0 then ShowMessage('数据提交成功') else ShowMessage('数据提交失败'); finally serial.DisposeOf; send.DisposeOf; url.DisposeOf; end; end;