o815 0 Posted May 5, 2023 Hi there, I was just wondering if anyone of you is using a cool de/serialization library (not JSON, something more "binary"). I am looking for something compact and want to avoid as much extra code as possible. Currently we are using (in my optionion (until now)) the coolest library: https://github.com/KrystianBigaj/kblib Note: Only cool if you don't use the de/serialized data out of delphi universe. What I like on this library, I can use just ONE LINE to de/serialize my structs (including Arrays etc): type //example definition of my data I want to de/serialize TStruct2 = record blabla : string; bla : boolean; end; TMyStruct = record foo : integer; foo2 : string; foo3 : TArray<Integer>; foo4 : TArray<TStruct2>; end; ... var s : TMemorystream; foo : TMyStruct; ... TKBDynamic.ReadFrom(s, foo , TypeInfo(TMyStruct)); // serialize data to memorystream TKBDynamic.WriteTo(s, foo , TypeInfo(TMyStruct)); // deserialize data from memorystream Does anybody out there know any similar and compact library (f.e. BSON) which can be easily used with a single line? When I look around, there is only something like this, which is too much overflow (in my opinion): https://docwiki.embarcadero.com/RADStudio/Alexandria/en/BSON Any suggestions? Share this post Link to post
Attila Kovacs 629 Posted May 5, 2023 1 hour ago, o815 said: Any suggestions? Ask a programmer to convert that BSON example into an universal one-liner class method. Share this post Link to post
timfrost 78 Posted May 5, 2023 You might like the Grijjy implementation of Google Protocol Buffers: https://blog.grijjy.com/2017/04/25/binary-serialization-with-google-protocol-buffers/ 1 Share this post Link to post
o815 0 Posted May 8, 2023 (edited) On 5/5/2023 at 11:48 PM, timfrost said: You might like the Grijjy implementation of Google Protocol Buffers: https://blog.grijjy.com/2017/04/25/binary-serialization-with-google-protocol-buffers/ Yeah man, that looks nice, thanks! I'll give it a try. I also found another interesting git project which supports a lot of serialization standards (but still a work in progress): https://github.com/SeanSolberg/DynamicDataObjects JSON, BSON, MsgPack (similar to "protocol buffer") .... Edited May 8, 2023 by o815 Share this post Link to post
Rollo62 536 Posted May 8, 2023 On 5/5/2023 at 11:48 PM, timfrost said: You might like the Grijjy implementation of Google Protocol Buffers: https://blog.grijjy.com/2017/04/25/binary-serialization-with-google-protocol-buffers/ https://blog.grijjy.com/2017/01/30/efficient-and-easy-to-use-json-and-bson-library/ Share this post Link to post
o815 0 Posted May 9, 2023 (edited) 22 hours ago, Rollo62 said: https://blog.grijjy.com/2017/01/30/efficient-and-easy-to-use-json-and-bson-library/ Thanks, I have seen this library, too. Problem is that BSON (or only this BSON library) is not supporting dynamic arrays: Quote Features The serialization engine supports the following features: [...] You can also serialize dynamic arrays to JSON (but not to BSON and TgoBsonDocument). I am using now the Grijjy implementation of Google Protocol Buffers which was suggested by "timfrost". The only uncool thing is that protocol buffers is not supporting 2D arrays (TArray<TArray<...>>) and TDatetime. TDatetime seems to be supported by the latest update of protocol buffer specification, but is not updated by Grijjy until now. BTW: I found another library which supports "messagepack". There's also a community version for free (but didn't test it): http://www.components4developers.com/products_kbmMW.html Edited May 9, 2023 by o815 Share this post Link to post