Boost logo

Boost :

Subject: [boost] Json read...segment by segment
From: vijay.singh_at_[hidden]
Date: 2015-07-06 02:45:52


Hi,

 

I am using below code to read load Json file in boost::property_tree::ptree
object. Function read_json(.) read all file content at a time. I want to
know is there any way to read file content segment by segment.

 

Thanks and regards,

Vijay

 

 

int _tmai3n(int argc, _TCHAR* argv[])

{

       try

       {

              std::stringstream ss;

 

              std::ifstream
file("D:\\EdisphereComp\\kit\\1003_Kit\\1003\\Inputfiles\\AI98_Test_3.json",
std::ios::binary);

 

              // Make sure we have something to read.

              if (!file.is_open()) {

                      throw (std::exception("Could not open file."));

              }

 

              // Copy contents "as efficiently as possible".

              ss << file.rdbuf();

 

 

              boost::property_tree::ptree pt;

              boost::property_tree::read_json(ss, pt);

 

 

 
boost::property_tree::write_json("D:\\EdisphereComp\\kit\\1003_Kit\\1003\\In
putfiles\\AI98_Test_3_sprite.json", pt);

 

 

       }

       catch (boost::property_tree::json_parser_error e)

       {

              ;

       }

 

       //}

       return 0;

}

 


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk