Skip to content

Fix example to not report syntax error on valid JSON input - #98

Open
rmisev wants to merge 2 commits into
kazuho:masterfrom
rmisev:fix-example
Open

Fix example to not report syntax error on valid JSON input#98
rmisev wants to merge 2 commits into
kazuho:masterfrom
rmisev:fix-example

Conversation

@rmisev

@rmisev rmisev commented Apr 4, 2017

Copy link
Copy Markdown

Adds parse_array_stop(size_t) override, which returns true, to
the root_context class in the streaming.cc example.

If not overriden, picojson::deny_parse_context::parse_array_stop(size_t)
returns false what causes syntax error.

Related issue: #82

@ooer

ooer commented Jul 6, 2017

Copy link
Copy Markdown

It would be great to pull at least commit f5fdb1f
It took me some time to fix the same problem.

Thank you.

Adds parse_array_stop(size_t) override which returns true to
the root_context class in the streaming.cc example.

If not overriden, picojson::deny_parse_context::parse_array_stop(size_t)
returns false what causes syntax error.

Related issue: kazuho#82
Used in the example std::istream_iterator skips whitespace and thus
a parser can produce unexpected reult, e.g.:

 Input: [{"x":"test space","y":20}]
 Output: "testspace",20

std::istreambuf_iterator does not skip whitespace, so is more
appropriate:

 Output: "test space",20

More info:
http://en.cppreference.com/w/cpp/iterator/istream_iterator (see "Notes"
section).
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.

2 participants