I am looking for a way to convert JSON to XML In C++.
For this we have evaluated PICOJSON and Pugixml.
I need some guidance and approach during initial coding on how to do this.
I am thinking of first Parsing the JSOn into and Object and then Iterated the Object recursively and construct XML using Pugixml
Code:
#include <iostream>
#include "include/picojson.h";
#include "include/pugixml.hpp";
using namespace std;
int main() {
const char* json =
"{"menu": {"
""id": "f","
""popup": {"
" "menuitem": ["
" {"v": "0"},"
" {"v": "1"},"
" {"v": "2"}"
" ]"
" }"
"}"
"}";
//const char* json = "{"a":1}";
picojson::value v;
std::string err;
const char* json_end = picojson::parse(v, json, json + strlen(json), &err);
std::string jsonres = v.serialize();
std::cout << v;
//How should I iterate on this "v" or "jsonres"
return 0;
}
How can I iterate the Parsed JSON Object, could someone guide me with initial code/sudo code