JSON <-> XML in C/C++

11,416

Solution 1

By far, the only specifically designed C++ library that directly converts XML to JSON I found on the Internet is xml2json: https://github.com/Cheedoong/xml2json

You can also convert JSON to XML if following the same rules.

Solution 2

Boost.PropertyTree handles both JSON and XML. There are some quirks in their implementations, so it wouldn't be a direct transformation, but it shouldn't need much work to adapt a property_tree between JSON and XML.

Solution 3

You could write a xslt for your xml document to convert to json. But I see no standard jslt for converting json.

Share:
11,416
Will I Am
Author by

Will I Am

Not Available

Updated on June 25, 2022

Comments

  • Will I Am
    Will I Am almost 2 years

    I've been searching to no avail for a set of routines to do conversion between JSON and XML. I have found such routines in Javascript, Java, PHP, and Python, but not in C or C++.

    FWIW, my json library is json-spirit. I am currently processing JSON, and would like to add XML support via a conversion layer (convert incoming messages from XML to JSON, process them, convert results back to XML, and them out).

    Does anyone have any pointers?

    I've also seen a number of references to badgerfish, rayfish, rabbitfish... encoding conventions, but they seem to point to dead URLs. Is there a reference somewhere which describes each convention?

    And yes, I've checked on json.org.