Im trying to read deflated json and experiencing type conversion problems, here is the code
boost::iostreams::filtering_streambuf<boost::iostreams::input> in;
std::istringstream iss(std::ios::binary);
iss.rdbuf()->pubsetbuf(buf, len);
iss.imbue( std::locale("ru_RU.CP1251") );
in.push( boost::iostreams::zlib_decompressor() );
in.push( iss );
boost::property_tree::ptree pt;
boost::property_tree::json_parser::read_json(in, pt); // <-- Compile error
Compiler says:
src/ABPacking.cpp:48: error: no matching function for call to
‘read_json(boost::iostreams::filtering_streambuf, std::allocator,
boost::iostreams::public_>&, boost::property_tree::ptree&)’
The question is how to pass filtering_streambuf to read_json without unnecessary data copying?
read_jsonexpects either a file name or a stream with the JSON content. You’re trying to pass a stream buffer, and it won’t know what to do with it.As a solution, just pass the stream buffer to an
istreamthat consumes it and pass that toread_json: