Is there a way to convert JSON to XML in C++? -


do know existing parsers ? there seem xml json, not other way.

if don't find on google, take json parser , write own converter using xml writer.

with dedicated data structure, such boost.propertytree, might both functionalities @ once

example:

using namespace boost::property_tree; static const std::string   json(""{\"my_point\":{\"name\":\"test point\",\"point\":{\"x\":1,\"y\":2,\"z\":3}}}"");  try {   ptree pt;   std::istringstream ss(json);   read_json(ss, pt);   std::ostringstream out;   write_xml(out, pt);   std::cout << out.str() << std::endl; } catch (std::exception &e) {   std::cerr << e.what() << std::endl; } 

output:

<?xml version="1.0" encoding="utf-8"?> <my_point><name>test point</name><point><x>1</x><y>2</y><z>3</z></point></my_point> 

that might not want. if is, consider path sketched in first sentence


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -