Are there any strict rules for conversion between JSON and XML?
Program I am working on should be able to output results in both formats, but among all the possible conversion utilities, libraries etc. I could not understand if there are any standard (possibly, "de-facto") for this conversion.
Common problems, as I see, are:
conversion from one format to other and then back should give result identical to original;
JSON have arrays - simple nesting of similar child items in the XML would not do, since some XML-processing tools would not preserve the order;
XML have attributes - their representation as a child items would change original XML when converting back.
Can I found any documentation on this question - or I may use any suitable converter because the lack of such standard?
Thank you in advance for links, advices, guides.
No... There is no strict rule as of yet.
As you imply... Although JSON can be converted to XML, the conversion cannot be robust , because XML tag lists are not, by definition, coupled to any particular data structure, where as JSON data structures are (maps and lists). Thus... JSON files , if converted to XML, cannot be losslessly converted back to JSON (unless of course you embed some nonstandard meta information in the JSON objects which are used for the XML decoding).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With