Take the 2-minute tour ×
Stack Apps is a question and answer site for apps, scripts, and development with the Stack Exchange API. It's 100% free, no registration required.

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?

share|improve this question
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 May 8 '13 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 May 21 '13 at 14:00
add comment

2 Answers

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.

share|improve this answer
add comment

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.

share|improve this answer
add comment

You must log in to answer this question.

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