Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow changing buffer size #27

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

rabidaudio
Copy link

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.

@ircmaxell
Copy link

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

@rabidaudio
Copy link
Author

@mrcodetastic
Copy link

Can you raise a pull request for

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

Because this library isn't maintained anymore it seems .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants