C++ boost parse dynamically generated json string (not a file)
What you can do is read the characters into a string stream, and then pass that to read_json
.
#include <sstream>#include <iostream>#include <boost/property_tree/json_parser.hpp>int main (int argc, char ** argv){ std::stringstream ss; ss << argv[1]; boost::property_tree::ptree pt; boost::property_tree::read_json(ss, pt); std::cout << pt.get<std::string>("foo") << std::endl;}
outputs
bar