Skip to content

Instantly share code, notes, and snippets.

@vinniefalco
Created November 15, 2019 16:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vinniefalco/2b7922fbdb4a543ce2f24ae91b6a2e45 to your computer and use it in GitHub Desktop.
Save vinniefalco/2b7922fbdb4a543ce2f24ae91b6a2e45 to your computer and use it in GitHub Desktop.
json::value
parse(std::istream& is)
{
json::parser p;
json::error_code ec;
p.start();
do
{
char buf[4096];
is.read(buf, sizeof(buf));
auto const n = is.gcount();
p.write(buf, n, ec);
if(ec)
throw json::system_error(ec);
}
while(! is.eof());
p.write_eof(ec);
if(ec)
throw json::system_error(ec);
return p.release();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment