RDP1974 40 Posted October 12 hi, can I ask your opinion about this JSON library to adopt? As much as there are good repositories for Delphi, in the last period I feel comfortable with this JsonTools (I handled all the blobs correctly from many devices where other libraries gave me errors in parsing) https://www.getlazarus.org/json/ https://www.getlazarus.org/json/tests/ (all test passed) btw. I am a loyal Delphi customer, I don't want to advertise Lazarus 🙂 Share this post Link to post
silvercoder79 25 Posted October 12 I am not one to tell you what you should or should not use... If you are familiar with it and works in the Delphi environment for you then go for it. I also do not have any experience in using the library you mentioned. The test results appear impressive. My own perspective is that is the tool already has the things I am looking for, I defer to those. In this instance, it would be : https://docwiki.embarcadero.com/RADStudio/Athens/en/JSON but if that does not meet your needs then ... Share this post Link to post
Arnaud Bouchez 407 Posted October 12 Personal biais: the mORMot 2 Open Source framework has a very efficient JSON library, and several ways to use it: - from RTTI, using classes, records, collections, dynamic arrays, mORMot generics... - from variants, and a custom "document" variant type to store JSON objects or arrays... - from high-level IDocList / IDocDict holders. See https://blog.synopse.info/?post/2024/02/01/Easy-JSON-with-Delphi-and-FPC It is perhaps the fastest library available, working on Delphi and FPC, with unique features, like: list := DocList('[{"a":10,"b":20},{"a":1,"b":21},{"a":11,"b":20}]'); // sort a list/array by the nested objects field(s) list.SortByKeyValue(['b', 'a']); assert(list.Json = '[{"a":10,"b":20},{"a":11,"b":20},{"a":1,"b":21}]'); // create a dictionary from key:value pairs supplied from code dict := DocDict(['one', 1, 'two', 2, 'three', _Arr([5, 6, 7, 'huit'])]); assert(dict.Len = 3); // one dictionary with 3 elements assert(dict.Json = '{"one":1,"two":2,"three":[5,6,7,"huit"]}'); // convert to JSON with nice formatting (line feeds and spaces) Memo1.Caption := dic.ToString(jsonHumanReadable); // integrated search / filter assert(DocList('[{ab:1,cd:{ef:"two"}}]').First('ab<>0').cd.ef = 'two'); 1 Share this post Link to post
RDP1974 40 Posted October 15 also there are many excellent libs (https://github.com/Fr0sT-Brutal/awesome-pascal) https://github.com/paolo-rossi/delphi-neon https://github.com/ahausladen/JsonDataObjects https://github.com/grijjy/GrijjyFoundation for now I have tested Hausladen JsonDataObjects : that's 3x faster than JsonTools and equally easy Delphi community is unbeatable! 1 Share this post Link to post
Die Holländer 49 Posted October 16 (edited) I like the native Delphi JSON Data Binding Wizard that creates objects for you by importing your JSON file.. neftali.clubdelphi json data binding wizard delphi 12 Edited October 16 by Die Holländer Share this post Link to post
RDP1974 40 Posted October 16 I also did this small test (parsing, path retrieve) over Grijjy.Bson, NesLib.Json, System.Json of course this test is not exhaustive, anyway Ahausladen is the fastest (D12.2 x64 Win11 24h2) Share this post Link to post
RDP1974 40 Posted October 16 On 10/12/2024 at 10:07 PM, Arnaud Bouchez said: Personal biais: the mORMot 2 Open Source framework has a very efficient JSON library, and several ways to use it: - from RTTI, using classes, records, collections, dynamic arrays, mORMot generics... - from variants, and a custom "document" variant type to store JSON objects or arrays... - from high-level IDocList / IDocDict holders. See https://blog.synopse.info/?post/2024/02/01/Easy-JSON-with-Delphi-and-FPC It is perhaps the fastest library available, working on Delphi and FPC, with unique features, like: list := DocList('[{"a":10,"b":20},{"a":1,"b":21},{"a":11,"b":20}]'); // sort a list/array by the nested objects field(s) list.SortByKeyValue(['b', 'a']); assert(list.Json = '[{"a":10,"b":20},{"a":11,"b":20},{"a":1,"b":21}]'); // create a dictionary from key:value pairs supplied from code dict := DocDict(['one', 1, 'two', 2, 'three', _Arr([5, 6, 7, 'huit'])]); assert(dict.Len = 3); // one dictionary with 3 elements assert(dict.Json = '{"one":1,"two":2,"three":[5,6,7,"huit"]}'); // convert to JSON with nice formatting (line feeds and spaces) Memo1.Caption := dic.ToString(jsonHumanReadable); // integrated search / filter assert(DocList('[{ab:1,cd:{ef:"two"}}]').First('ab<>0').cd.ef = 'two'); Hi, is it possible to use a retrieval path method for example on a list with multiple arrays inside? Many libraries offer a subset of https://goessner.net/articles/JsonPath/ for simple retrievals. Share this post Link to post
Die Holländer 49 Posted October 16 (edited) I've got thousands of large JSONS in the same format (like with intake data for many persons..) each with many objects and array's where the people wanted to do searching. I tried many Delphi JSON programming libraries but ended up by adding all the plain JSONS as records in the MSSQL database and wrote a SQL-View using the "OPENJSON" rowset function Now I can do: Select * FROM [View_JSON] where field=value Even better.. You can just do joins with "normal" tables.. Select * FROM [View_JSON_] left join myNormalTable on [View_JSON].field=myNormalTable.field=value and the speed.? Edited October 16 by Die Holländer Share this post Link to post
Alexander Sviridenkov 360 Posted October 16 SQL framework from HTML Library Bundle can execute SQL queries on JSON, XML, Datasets, Lists, arrays, lists of objects, CSV files, etc. Share this post Link to post
David Heffernan 2353 Posted October 16 Different use cases will suit different libraries. You gave no indication of what your motivations and goals are. Share this post Link to post
RDP1974 40 Posted October 16 eg. a typical TCP chat client server, with a common protocol as discord or whatsapp or old msn. Share this post Link to post