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

Issue75stopwhendone #83

Merged
merged 3 commits into from
Jul 28, 2014
Merged

Issue75stopwhendone #83

merged 3 commits into from
Jul 28, 2014

Conversation

miloyip
Copy link
Collaborator

@miloyip miloyip commented Jul 27, 2014

Fix #75
SkipWhitespace() was not modified as @pah suggest, yet.
Actually user may not use this after the stream has parsed a JSON, SkipWhitespace() is only defined for JSON.
Would ask @pah for review.

@miloyip miloyip self-assigned this Jul 27, 2014
@pah
Copy link
Contributor

pah commented Jul 28, 2014

Compared to the discussion in #75, it's a simple but effective approach.

Generally, I liked the idea of making this the default behaviour, except for the insitu parsing.

It seems that it is now possible to read multiple objects without an explicit Reset of the Reader in-between? Should this be required for safety?

SkipWhitespace() was not modified as @pah suggest, yet.
Actually user may not use this after the stream has parsed a JSON, SkipWhitespace() is only defined for JSON.

I don't understand this concern. Yes, it is (kind of) an JSON-related function, but it should work also outside of the Parse* functions?

@miloyip
Copy link
Collaborator Author

miloyip commented Jul 28, 2014

Generally, I liked the idea of making this the default behaviour, except for the insitu parsing.

Actually insitu parsing should be fine with kParseStopWhenDoneFlag. These two features should be orthogonal.

It seems that it is now possible to read multiple objects without an explicit Reset of the Reader in-between? Should this be required for safety?

Yes. This is safe for continue parsing with the same stream. Reader does not need Reset() because everytime it passes the stream to ParseStream() but stream of Writer is set at constructor. I forgot about this thus proposed a wrong idea previously.

I don't understand this concern. Yes, it is (kind of) an JSON-related function, but it should work also outside of the Parse* functions?

If the stream contains things other than JSON, I think should not suggest user to use SkipWhitespace() before/after the JSON section. But user can do that if they like to.

miloyip added a commit that referenced this pull request Jul 28, 2014
@miloyip miloyip merged commit e6f3446 into master Jul 28, 2014
@pah
Copy link
Contributor

pah commented Jul 28, 2014

If the stream contains things other than JSON, I think should not suggest user to use SkipWhitespace() before/after the JSON section. But user can do that if they like to.

Indeed, the user should explictily consume whitespace, if necessary in the application. My suggestion has been to fluently return the stream itself from this function for convenience, e.g. reusing the stream in another context again.

@pah
Copy link
Contributor

pah commented Jul 28, 2014

Actually insitu parsing should be fine with kParseStopWhenDoneFlag. These two features should be orthogonal.

Currently, there is no way to obtain the "end" of the first JSON object after the insitu parsing, at least for the ParseInsitu(Ch*) overloads in GenericDocument. I think, we should force !kParseStopWhenDone in these cases.

Do you still intend to make this the default behaviour? (i.e. rename it to kParseConsumeFullStream)?

@miloyip miloyip deleted the issue75stopwhendone branch July 29, 2014 05:02
miloyip added a commit that referenced this pull request Jul 29, 2014
@miloyip
Copy link
Collaborator Author

miloyip commented Jul 29, 2014

Insitu parsing can be done with Reader::Parse<kParseInsituFlag>(Stream, Handler) or Document::ParseStream<kParseInsituFlag>(Stream).

For string stream, user also need to call ParseStream() instead of Parse(Ch*), in order to retain the stream between multiple parses.

I am considering setting kParseDefaultFlags = kParseStopWhenDoneFlag.

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.

Allow Reader to read only one/first JSON object
2 participants