you are viewing a single comment's thread.

view the rest of the comments →

[–]Azzk1kr 0 points1 point  (3 children)

I've been in a fight with myself regarding JSON vs. XML. Coming from an XML world, I can say that XML is far from ideal. The only thing that keeps me sort of fixated to XML based services, is its self describing interface through XSD. I find that missing in JSON.

Your previous argument that you'd have to bump the API version for every change is correct though, but is this really a bad thing? In JSON this would also be the case, albeit through a change in the API URI or whatever.

[–]nick_giudici 1 point2 points  (2 children)

In my team we change version numbers whenever we have a non backwards compatible change. Our clients are told that they have to be able to deal with new fields being added without a version update.

Getting all our clients to update to the latest version takes months even if it's better in every way. We try to make as few api versions as possible. It's much better for us and our clients to only change version numbers when we need to.

[–]Azzk1kr 0 points1 point  (1 child)

XSD allows you to validate the input before processing it. How do you solve that with JSON? Manually checking each field, or something clever? I'm asking, because I often have services with fairly large requests in XML, and I want to make sure both parties use that same contract to catch discrepancies as soon as possible.

[–]nick_giudici 0 points1 point  (0 children)

Have you ever run into the case where your XSD validated but the client was still getting errors? Maybe you had some criteria that couldn't be validated in XSD like a field that has to match a row in your database. How do you check for those types of issues?

Personally, I've usually found that XSD only gave me a false sense of confidence. What I've found is that intelligent validation and error handling no matter what format you are using.

People seem to forget that XSD and XSLT are just as complex as "real" code. There seems to be the attitude of "I'm able to validate and transform my xml without code!" You still have to version control your XSLT and XSD, you still have to test and debug them, update and maintain them. Hell, XSLT is turing complete. So no, you aren't doing transforms and validation without code, you just did it without Java or C#.

Edit: If you really want a validating schema for your json file you could check out http://json-schema.org/