tags:

views:

68

answers:

3

I'm going to create a restful api in Json to provide data to my customers.

I really prefer json over xml. All my coding is done in json.

I wonder, is it sufficient to just provide json api and tell the customers through the homepage that json rocks over xml and we only use json, or are there a lot of customers that just prefer xml and don't want to switch?

What are your thoughts and experiences?

+4  A: 

It depends on your customers. Build the JSON interface, debug it and launch it. If your customers ask for XML, build an XML interface.

Troy J. Farrell
+2  A: 

I've built several APIs that are shared for web and mobile applications. As Troy mentioned, I normally build them for the specification. However, I find later that I end up supporting additional formats. I allow the client to request the format using the HTTP Content-Accept header.

Really this is more about implementation. If you have a framework or develop your API methods well, expanding the response format, say from XML to JSON, should be trivial.

Jason McCreary
+2  A: 

I agree with Troy; and in my opinion it is service provider that defines interfaces. Offering multiple somewhat equivalent alternatives (as in, both xml and json can be used for exposing data) does not necessarily help clients; sometimes it is just more confusing. And there is usually more maintenance and more testing for service provider, and may possibly have different issues with variants. So I prefer exposing a single well-designed interface unless there are clear reasons for offering alternatives.

As a client it is enough for me to have one well-working way (one supported by tool sets I use or can use) and beyond that it's more of nice-to-have: I too prefer JSON, but if I get XML it is what it is and works well enough.

StaxMan
Yeah .. i think that is important to know what to use and focus on than providing everything, even solutions that are obsolete. Only this way technology will move forward. I think I won't provide XML Restful API if it's not absolutely necessary.
never_had_a_name
True. On plus side, some frameworks make it easy to expose similar interfaces, like JAX-RS for xml and json. In those cases it is at least easier to open up more based on customer preferences.
StaxMan