| 23 | namespace json = boost::json; |
| 24 | |
| 25 | json::value |
| 26 | parse_file( char const* filename ) |
| 27 | { |
| 28 | file f( filename, "r" ); |
| 29 | json::stream_parser p; |
| 30 | boost::system::error_code ec; |
| 31 | do |
| 32 | { |
| 33 | char buf[4096]; |
| 34 | auto const nread = f.read( buf, sizeof(buf) ); |
| 35 | p.write( buf, nread, ec ); |
| 36 | } |
| 37 | while( ! f.eof() ); |
| 38 | if( ec ) |
| 39 | return nullptr; |
| 40 | p.finish( ec ); |
| 41 | if( ec ) |
| 42 | return nullptr; |
| 43 | return p.release(); |
| 44 | } |
| 45 | |
| 46 | void |
| 47 | pretty_print( std::ostream& os, json::value const& jv, std::string* indent = nullptr ) |