A xml and json foramt converter
What can it do ?
This library depends on cJSON and ezxml, both of library are written in C. So do this converter.
Basically, this converter can transform most of the xml format file into json format, and vice versa (in my opinion).
How to set up ?
- To create the converter static library.
make
- To create two example executable files by the name of
test_json2xml
which convert json to xml andtest_xml2json
which convert xml to json on the other hand.
make test
Know the limitation
While transforming a json into a xml, there will appear two tags which you may not familiar.
pseudoTag
tag is used to handle the most outside braces in json format. For example,This will be converted to the following.{ "name" : "Tom", "age" : 23, "gender" : "Helicopter" }
<pseudoTag> <name>Tom</name> <age>23</age> <gender>Helicopter</gender> </pseudoTag>
pseudoIndex
tag is used to deal with nested array in json format. For examlpe,This will be converted to the following.{ "doubleArr" : [[[3,5,4]], [false, true, false]] }
<pseudoTag> <doubleArr> <pseudoIndex> <pseudoIndex>3.00</pseudoIndex> <pseudoIndex>5.00</pseudoIndex> <pseudoIndex>4.00</pseudoIndex> </pseudoIndex> </doubleArr> <doubleArr> <pseudoIndex>false</pseudoIndex> <pseudoIndex>true</pseudoIndex> <pseudoIndex>false</pseudoIndex> </doubleArr> </pseudoTag>
- This library does't have any pretty print function in xml format, so you have to use some online tools to make it easier to read.