Your question doesn't precisely identify your input and expected output. Are you parsing the C++ from a file? I can't tell.
If the first code block is an autogenerated input file and will always have that whitespace pattern and the JSON equivalent is your desired output, replace the first line with "[\n" and the last line with "]/n" and you're done.
If you can't guarantee the white space pattern of the input file, then you will need a C++ parser to generate an AST (abstract symbol tree) that you can traverse to find the faceIds array RHS (right hand side) and then do the same thing as shown below from that AST collection.
If you simply want to iterate in C++ through faceIds, then the following code should produce the desired JSON string:
#include <iostream>
#include <sstream>
std::string faceIds[] = {
"29e874a8-a08f-491f-84e8-eac263d51fe1",
"6f89f38a-2411-4f6c-91b5-15eb72c17c22",
"7284b730-6dd7-47a3-aed3-5dadaef75d76",
"1fc794fa-3fd4-4a78-af11-8f36c4cbf14c",
"3e57afca-bd1d-402e-9f96-2cae8dbdfbfa",
"c2a4e0f5-4277-4f5a-ae28-501085b05209",
"23b5910e-9c32-46dd-95f3-bc0434dff641"
};
int main() {
std::ostringstream ostr;
ostr << '[' << std::endl;
int last = std::extent<decltype(faceIds)>::value - 1;
int i = 0;
while (i < last)
ostr << " \"" << faceIds[i ++] << "\"," << std::endl;
ostr << " \"" << faceIds[i] << "\"" << std::endl;
ostr << ']' << std::endl;
std::cout << ostr.str();
return 0;
}
If you want some library's object representation, then you'll have to identify what library you are using so we can review its API. Whatever library you use, you could always just run whatever parse method it has on ostr.str() above, but we could find a more efficient method to build the equivalent JSON tree if you identified the JSON library. One can't uniquely identify the library from an object name like JSONObject, which is a class name used in dozens of libraries.