I have this code that I need to parse/or get the JSON array as std::string to be used in the app.
std::string ss = \"{ \\\"id\\\" : \\\"123\\\", \\\"number\
continue with @sehe 's answer, related to the question asked by @xkm
Is it possible to get it like '[{ "name" : "some" }, { "name" : "stuffs" }]'
Yes, you can. Just treat it with an "unnamed" key which means the key with empty string.
f.g.
#include
#include
#include
using boost::property_tree::ptree;
int main()
{
std::stringstream ss;
ss << R"([{"a": 5}, {"a": 9}])";
ptree pt;
read_json(ss, pt);
for (auto& item : pt.get_child(""))
std::cout << "value is " << item.second.get("a") << std::endl;
}