1

I am working on an application which uses the Stack Exchange API. But I don't want responses in JSON format.

So, if I want to convert JSON to another format like XML, is there any way to get the server itself to reply in XML format? Or is it my responsibility to do this conversion?

2
  • 2
    Can you tell us why you want the data in XML format? Most programs I can imagine someone building would be on the client side, and JSON tends to work really well natively with JavaScript. Perhaps explaining more about what you're trying to do would help us understand the importance of having access to this data in XML format. Hope this helps!
    – jmort253
    Commented May 8, 2013 at 6:10
  • JSON format was specifically picked to ensure speedy transport of the data (XML is much more verbose than JSON) and is the preferred format for REST based services today. I'd highly advise adopting using JSON format on 'your' end too. (regardless of the app)
    – scunliffe
    Commented May 21, 2013 at 14:00

2 Answers 2

2

JSON is faster and more compact, so it is easier on the server, and easier to parse in most application languages -- while still being human-readable.

Since the API is returning data, rather than markup, JSON is a much better choice than XML.

If you insist on XML, there are a great   many   ways   to convert the data yourself, without loading the API servers with extra XML baggage.

0

The API only returns data in JSON format - you must perform any conversion yourself.

Here is the source code for a PHP app I wrote a while back that converts the JSON returned by the API to XML:

http://quickmediasolutions.com/pastebin/1/stack2xml-source-code

It expects two GET variables to be set:

  • method - the API route to use (for example, questions)
  • version - the API version to use (for example, 2.0)

These are in addition to any regular query string parameters expected by the API.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .