Jump to content
Sign in to follow this  
RDP1974

which JSON library

Recommended Posts

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

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

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');

 

  • Like 1

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×