tags:

views:

31

answers:

1

Hey, I have a quiz really soon, and part of it is translating between JSON and XML. How do I do this?

+1  A: 

JSON to XML

Parse the JSON data, create a new XML document with the appropriate library and put the data from the parsed JSON in there.

XML to JSON

Parse the XML document, put it in some native object and encode that as JSON.


If you don't tell us in which language you want to do it, you won't get any more precise answers. After all both JSON and XML are used to encode data, and as such both are completely interchangeable, you just need to use the output of one decoder as the input of the other encoder..

poke
I'm talking about translating it by hand. Like being able to write out XML code from JSON and vice versa.
b1877243
By hand? Maybe you should first learn how about the actual format of both XML and JSON. Then it will be quite obvious how to put things into another format. You just need to be able to decode the stuff in your mind and encode it correctly in the other format. There is no magic involved, and basically you are working the same as you would with code.
poke