I'm using RapidJSON to parse large GeoJSON files. Most of the content in these files (and hence memory after parsing) is giant coordinate arrays. For my application, I'm not interested in these. I'd prefer to skip them (not allocate memory for them) while parsing. Based on some testing using the SAX API, I expect this to roughly double the speed of parsing.
My initial thought was to write a custom Handler. I'd have to build up my own Value object using my own stack, however, work which would duplicate what's done by the GenericDocument
class.
My next thought was to subclass GenericDocument
. Its ParseStream
and Handler methods aren't virtual
, however, so I can't get it to use my own. I could implement my own ParseStream
, but the stack_
field is private, so even a subclass can't access it.
Is a custom Handler with its own Stack the right way to go here? Has anyone done something like this before?