[fpc-pascal] Tests results of several pascal based JSON parsers

Michael Van Canneyt michael at freepascal.org
Sat Aug 31 11:34:53 CEST 2019



On Sat, 31 Aug 2019, Benito van der Zander wrote:

> Hi,
>
> when I need maximal speed, I use jsonscanner of fpJSON. It should be 
> vastly faster than a complete parser by not allocating memory or 
> validating the json.
>
> Although it decodes all the strings in the JSON, which require some 
> allocations, even if you do not need every string.
> It would be faster, if it would just set a (pchar, length) pair for each 
> string. The CurTokenString property could be changed from returning the 
> already decoded string to a method decoding the string only when the 
> property is read.

Indeed, that is also why the JSONParser/JSONReader  exists.

It allows a SAX-like approach to JSON, which is really important when dealing with
huge documents.  If you need to insert data at high speed in a database, you
don't need the whole JSON Document which would allocate huge amounts of
memory (at least twice the original JSON stream).

You use JSONSReader and handle record by record.

As I said, the scope of fpJSON is much bigger than the JSONtools approach.
It simply became so out of necessity.

I'm currently implementing a speed improvement, but your suggestion is
interesting and will probably result in even more speed enhancements.

Michael.


More information about the fpc-pascal mailing list