It's your experience vs the industry consensus. The industry is currently shifting away from HTML services and to JSON.
My belief as to why is that HTML is a markup language specifically meant for display in a web browser and JSON is an object serialization format. Even with pure XML you have issue when you have a block like:
<issues>
<issue>Data</issue>
</issues>
Should issues be represented internally as an object/map or as an array? Will I ever get more than 1 issue tag? In JSON you have maps and arrays that map directly to the native constructs in your language in a 1 to 1 fashion. XML has a many to many relationship. I have at least 3 ways to represent key/value pairs in XML but only 1 in JSON. I have structures in XML where I'm not sure if they are an array or a key value pair map.
The common way to solve this in xml is by using a schema but that is the definition of brittle. Now you have to bump the api version for every little change even if you are just adding a field. In a JSON based service this is not the case.
Then we add in the fact that for correct display in your page you will likely need classes and divs that are not data. Those are clearly display markup and make your data tightly coupled with the display. Your xpath ends up not representing your business data instead ends up representing your display structure.
I hope you heard of semantic markup. And give me one crawler/search engine of JSON resources. I give you few search engines of HTML resources: google.com bing.com duckduckgo.com
Wow, you are being very immature about this. Are you actually insulted that someone doesn't like html/xml as much as you?
I know about semantic markup but you failed to address the other issues that I talked about with xml and html in general. Also, the industry has spoken and is moving away from having web services returning directly displayable markup. Here's what I was able to lookup for you.
Json is smaller, parses much faster with less client cpu usage (great for mobile), you don't have to use xpath which is slow as hell and completely outside the natural paradigms of most languages, and has less edge cases where it fails like empty or single element arrays.
Just because mac osx ruby node.js mongodb shit fucks go batshit cray about JSON web scale yolo fest, you don't have to be sold on them. Please use angularjs yeoman bower gruntfiles.
Hey look at that, I can put hypermedia into a document as the engine of application state no matter if I'm using JSON or XML!
As a side note, in our tests parsing the xml and accessing the data through xpath was 10 times greater cpu load than parsing and access of json.
Even your rage is nonsense. osx is just a 15 year old BSD distro. Not exactly cutting edge, ruby and node are direct competitors, and none of these have ANYTHING to do with the choice between json and xml.
15
u/nick_giudici Mar 18 '14
It's your experience vs the industry consensus. The industry is currently shifting away from HTML services and to JSON.
My belief as to why is that HTML is a markup language specifically meant for display in a web browser and JSON is an object serialization format. Even with pure XML you have issue when you have a block like:
Should issues be represented internally as an object/map or as an array? Will I ever get more than 1 issue tag? In JSON you have maps and arrays that map directly to the native constructs in your language in a 1 to 1 fashion. XML has a many to many relationship. I have at least 3 ways to represent key/value pairs in XML but only 1 in JSON. I have structures in XML where I'm not sure if they are an array or a key value pair map.
The common way to solve this in xml is by using a schema but that is the definition of brittle. Now you have to bump the api version for every little change even if you are just adding a field. In a JSON based service this is not the case.
Then we add in the fact that for correct display in your page you will likely need classes and divs that are not data. Those are clearly display markup and make your data tightly coupled with the display. Your xpath ends up not representing your business data instead ends up representing your display structure.