Skip to content

Instantly share code, notes, and snippets.

@vinniefalco
Created November 16, 2019 02:59
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/bde6ccdc46d62819109f18ba284aa0f8 to your computer and use it in GitHub Desktop.
Save vinniefalco/bde6ccdc46d62819109f18ba284aa0f8 to your computer and use it in GitHub Desktop.
json::value
parse_file( char const* filename )
{
json::error_code ec;
file f;
f.open( filename, "r", ec );
if(ec)
throw json::system_error(ec);
json::parser p;
p.start();
do
{
char buf[4096];
auto const nread = f.read( buf, sizeof(buf), ec );
if(! ec)
p.write( buf, nread, ec );
if( ec )
throw json::system_error(ec);
}
while( ! f.eof() );
p.finish(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