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

Check for trailing characters when parsing std::string. #70

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

Conversation

greggomann
Copy link

Thanks for the awesome library, kazuho! This issue came up in my work recently, and I thought I'd offer a patch to address what seems to me to be erroneous behavior:

When parsing a stream, it makes sense to return successfully if a valid JSON value is streamed in, regardless of what comes afterward. When parsing a std::string, however, I think it's appropriate to return an error if any non-whitespace trailing characters are detected. In the case of parse(value, std::string), it only makes sense for the input string to contain a single valid JSON value, and comprehensive error checking should catch if this is not the case. This patch checks for such trailing characters and returns an error if they are present. Thoughts?

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.

1 participant