json-streaming-parser icon indicating copy to clipboard operation
json-streaming-parser copied to clipboard

Allow changing buffer size

Open rabidaudio opened this issue 6 years ago • 3 comments

I have a pretty memory-tight application and the parser buffer size of 512 was way overkill for my use-case (the largest individual keys/values are around 20 chars). I'm apparently not the first to have this issue. #19

This PR allows you to override the buffer size, either through build flags or by defining the prop before the library is imported:

#define JSON_PARSER_BUFFER_MAX_LENGTH 128
#include <JsonStreamingParser.h>

I renamed the definition to reduce the chance of conflicts with definitions in other code.

rabidaudio avatar Jul 19 '19 22:07 rabidaudio

Note: you'll also need to modify increaseBufferPointer() in JsonStreamingParser.cpp, which also refers to BUFFER_MAX_LENGTH:

void JsonStreamingParser::increaseBufferPointer() {
  bufferPos = min(bufferPos + 1, BUFFER_MAX_LENGTH - 1);
}

ircmaxell avatar Feb 09 '20 13:02 ircmaxell

@ircmaxell thanks for the heads up, that function got changed: https://github.com/squix78/json-streaming-parser/pull/27/files#diff-5a1f311800a154b95827c7c76e82f0c1R205

rabidaudio avatar Mar 05 '20 00:03 rabidaudio

Can you raise a pull request for

https://github.com/mrfaptastic/json-streaming-parser2

Because this library isn't maintained anymore it seems .

mrcodetastic avatar Dec 27 '22 17:12 mrcodetastic