L
L
LittleBuster2014-11-04 00:54:42
JSON
LittleBuster, 2014-11-04 00:54:42

How to parse json from a string (boost)?

I have a perfectly working example of parsing a json file, but the question is, how can I parse a json string without loading it from a file, but, let's say, taking it from std::string?

std::ifstream ifs("config.json");
boost::property_tree::ptree pt;
boost::property_tree::read_json(ifs, pt);
string s( pt.get<string>("responseData.id") );
cout << s << endl;

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Rsa97, 2014-11-04
@LittleBuster

Use std::istringstream instead of std :: ifstream

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question