Closed hassanfarid closed 8 years ago
Iterate through the vector and use Json::parse
on each string, build up a vector<Json>
, then convert the result to Json
I found a solution myself:
Use Json::array constructor,
Json j = Json::array({vector_of_string_with_json_formatted_string});
cout<<j.dump();
this would result in string: "[[{"key":"value"}, {"key":"value"}]]"
so then you can use below code to get required object format,
cout<<j[0].dump();
I forgot the solution that I found earlier, and found it useful finding it here. Thanks myself. :)
I have std::vectorstd::string each string value is json object = "{"key":"value"}"
How can make a Json::object of value "[{"key":"value"}, {"key":"value"}]"