Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JSON <-> XML in C/C++

Tags:

c++

json

c

xml

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.

like image 457
Will I Am Avatar asked May 03 '26 14:05

Will I Am


2 Answers

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.

like image 171
Cheedoong Avatar answered May 05 '26 04:05

Cheedoong


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.

like image 34
K-ballo Avatar answered May 05 '26 03:05

K-ballo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!