I have this code that I need to parse / or get a JSON array as std :: string to be used in the application.
std::string ss = "{ \"id\" : \"123\", \"number\" : \"456\", \"stuff\" : [{ \"name\" : \"test\" }] }"; ptree pt2; std::istringstream is(ss); read_json(is, pt2); std::string id = pt2.get<std::string>("id"); std::string num= pt2.get<std::string>("number"); std::string stuff = pt2.get<std::string>("stuff");
It is necessary that the "material" be obtained in this way as std :: string [{ "name" : "test" }]
However, the code above stuff just returns an empty string. What could be wrong
c ++ boost
xkm
source share