Steve Maughan 26 Posted July 7, 2021 I need to read and parse a large JSON file (of geographic data) as fast as possible. I'd prefer to use Delphi's own classes but I'm not adverse using a third party component if it's measurably faster. What's the best way to do this? Thanks, Steve Share this post Link to post
Remy Lebeau 1396 Posted July 7, 2021 (edited) Have you read Delphi's JSON documentation yet? Particularly the "Reading a JSON With Different Frameworks" examples in the Readers and Writers JSON Framework section. Also see Readers and Writers JSON Framework: Reading JSON Objects Edited July 7, 2021 by Remy Lebeau 1 Share this post Link to post
Steve Maughan 26 Posted July 7, 2021 40 minutes ago, Remy Lebeau said: Have you read Delphi's JSON documentation yet? Particularly the "Reading a JSON With Different Frameworks" examples in the Readers and Writers JSON Framework section. Also see Readers and Writers JSON Framework: Reading JSON Objects Thanks Remy — yes, I've take a look. The examples are threadbare to say the least. Steve Share this post Link to post
Stefan Glienke 2002 Posted July 7, 2021 (edited) Isn't fastest and using Delphi's own classes mutually exclusive? My personal recommendation goes to https://github.com/ahausladen/JsonDataObjects Edited July 7, 2021 by Stefan Glienke 6 2 Share this post Link to post
Edwin Yip 154 Posted July 8, 2021 Implemented natively in Delphi, as Stephen suggested: https://github.com/ahausladen/JsonDataObjects Maybe world's fastest: Simdjson, however, there is no complete Delphi wrapper yet, but this one-function only wrapper can get you started quickly if you go this route: https://synopse.info/forum/viewtopic.php?id=5926 Share this post Link to post
sakura 45 Posted July 8, 2021 Alternatively try https://github.com/synopse/mormot2 - the mormot.core.json and mormot.core.variants units contain what you would need. Share this post Link to post
Fr0sT.Brutal 900 Posted July 8, 2021 If the file is large enough to exceed available memory, probably you'll want to use stream-like parser, like SAX from XML. Grijjy has something alike https://blog.grijjy.com/2017/01/30/efficient-and-easy-to-use-json-and-bson-library/ 1 Share this post Link to post
Kim Madsen 4 Posted July 8, 2021 kbmMW's JSON parser is pretty fast. If you have Delphi Berlin, you can visit https://portal.components4developers.com, register and download kbmMW Community Edition which is free. It contains the native JSON, XML, BSON, MessagePack, YAML and CSV parsers/generators. Share this post Link to post
Vincent Parrett 750 Posted July 8, 2021 14 hours ago, Fr0sT.Brutal said: Grijjy has something alike https://blog.grijjy.com/2017/01/30/efficient-and-easy-to-use-json-and-bson-library/ The same author has another json parser library - see here https://github.com/neslib/Neslib.Json/issues/5 - I have not used it yet but plan to very soon. Share this post Link to post
Fr0sT.Brutal 900 Posted July 9, 2021 8 hours ago, Vincent Parrett said: The same author has another json parser library - see here https://github.com/neslib/Neslib.Json/issues/5 - I have not used it yet but plan to very soon. Good point - I wasn't aware these two differ. And Neslib's implementation has stream parsing as well. Share this post Link to post
Tommi Prami 130 Posted July 13, 2021 Has anyone done any benchmarking lately on JSON libs? Ones I have seen are bit old I think. (I am not needing one right now, but would be good for the community if someone woulöd do something like that) .Tee. 1 Share this post Link to post