2

Parse JSON and create XML formatted file that still represents the data. (SuperXMLParser adds all the #children/#name tags). Parse XML and create a JSON formatted file. (arrays/objects/...)

Use a generic object but create correct JSON/XML data from the generic object. Or do I have to use a specific object in order to get the correctly formatted output formats?

user3745651
  • 21
  • 1
  • 3
  • It's possible. I've seen code for it, but that was at a previous job and I no longer have it available. – Mason Wheeler Jun 17 '14 at 18:54
  • You could use XSLT to create JSON from XML. – Graymatter Jun 17 '14 at 19:03
  • What about from Delphi? – user3745651 Jun 17 '14 at 19:12
  • See http://stackoverflow.com/questions/982687/how-do-i-display-xml-using-an-xslt-document-in-a-delphi-app and https://code.google.com/p/xml2json-xslt/ – Graymatter Jun 17 '14 at 19:21
  • Yeah Warren sort of the same issue. I thought I had all the issues worked out but when I got to testing everything then (numbers/integers/boolean/...) were no longer correct/same. So the scope of my task has grown larger now. (attributes and so on) – user3745651 Jun 17 '14 at 19:28

1 Answers1

1

For TMongoWire I created a JSON parser that fills a IBSONDocument object, which is basically a key-value-collection based on OleVariant's:

https://github.com/stijnsanders/TMongoWire/blob/master/bsonUtils.pas

That answers the part of the question about converting without deserialization. To generate the XML you could copy JsonToBson but generate XML instead.

Stijn Sanders
  • 35,982
  • 11
  • 45
  • 67