17 ms·
1 in 5 APIs Say “Bye XML” - JSON gaining ground
- mildweed 16y agoLarge data sets should be published in XML. Small transactional exchanges (already contextual) should be JSONP.
- rb2k_ 16y agoI agree, another way of phrasing this would be: - XML is for documents - JSON is for data-structures Both of them do a great job in their domain, but you shouldn't try to mix them up and store data-strctures in XML or Documents in JSON
- MatthewPhillips 16y agoIf we had a JSON query language as powerful as XPath would you feel the same way? I can't think of any other reason for agreeing with you (thought XPath is reason enough). Edit: While underscore.js is wonderful, I doubt it performs nearly as well as XPath.
- masklinn 16y ago> I can't think of any other reason for agreeing with you (thought XPath is reason enough). Streaming JSON API/parsers are not wide-spread (and definitely not as widespread as SAX-style streaming XML parsers), which makes JSON unusable for datasets which don't fit in memory. And generally spreaking, I think most people would be satisfied with a CSS-type query language, I'm always surprised by the dislike my colleagues have for xpath and their lack of knowledge of it, even though xpath is one of the very few things I like in the XML infosphere (the other one being RelaxNG)
- Xurinos 16y agoIs the real pro-XML argument, then, that it currently has support? As far as I know, there is nothing inherent to JSON to prevent anyone from writing a streaming parser.
- deleted 16y ago[deleted]
- masklinn 16y ago> Is the real pro-XML argument, then, that it currently has support? That's the only one I can find which would be relevant to milweed's assertion that: > Large data sets should be published in XML. Apart from the rarely used ability to mix data formats into a single semi-coherent document and some sort of backwards compatibility, I don't see much in the way of reason. > As far as I know, there is nothing inherent to JSON to prevent anyone from writing a streaming parser. Of course there is not, and there are several such parsers, hence my writing that they are not widespread. Were they impossible (or non-existent) or at the very least unknown to me I'd have written that they don't exist instead.
- xtian 16y agoJSONSelect (http://jsonselect.org http://jsonselect.org) provides a CSS-like query syntax for JSON. I haven't used it much yet, though, so I don't know how it performs.
- lloydhilaiel 16y agoAs for streaming JSON parsers: https://github.com/lloyd/yajl https://github.com/lloyd/yajl Around for four years. Stable. Language bindings for all major languages.
- epistasis 16y agoI guess it depends on your definition of "large," but I would say that large is where XML is at its very worst. When data can't fit in main memory, then the XML overhead provides no benefit and incurs a great cost. I would argue that data in general does not fit well to XML. Documents do fit well as it's absolutely fantastic at markup, i.e. where there isn't repeated structure. As soon as you have repeated structure (i.e. data as opposed to datum) then XML becomes a terrible format. CSV, tab-delimited, gzipped and separated by pipe characters, RDF triples, N3, give me almost •anything* other than XML and I'll be much happier. In fact, XML is the reason that RDF is dead in the water. RDF could have been a useful concept, but it's so encumbered by a terrible formats and tools that it will almost never be useful; it can not escape the existing body of XML-RDF. And such a waste in the name cargo-cult mimicking of HTML.
- snprbob86 16y ago> much of the reason XML is complex is that it’s trying to solve complex problems of data interchange by providing a meta language to describe the data. As JSON gains wider adoption, it will face some of the same issues XML tackled over the last decade. shrug I don't actually think these problems are all that complex. XML made them complex. The bottom line is that you need to treat any data format as a protocol. The only thing you need to know about the data is what protocol it is. A simple file extension pretty much takes care of that. Then each data format can pick whatever (in)formalism they want to describe the protocol. JSON is popular precisely because it doesn't try to solve any non-problems.
- gaius 16y agoNot only are they not complex, they were solved in the 80s. http://en.wikipedia.org/wiki/Abstract_Syntax_Notation_One http://en.wikipedia.org/wiki/Abstract_Syntax_Notation_One
- __rkaup__ 16y agoJSON has a nice way of reinventing that wheel on their website. http://json.org/ http://json.org/
- brnstz 16y ago> JSON is popular precisely because it doesn't try to solve any non-problems. This reminds me of Erik Naggum's XML rant: http://www.schnada.de/grapt/eriknaggum-xmlrant.html http://www.schnada.de/grapt/eriknaggum-xmlrant.html "If a solution is much smarter than the problem and really stupid people notice it, they believe they have got their hands on something /great/, and so they destroy it . . ."
- JonoW 16y agoI find the whole JSON vs XML debate pretty tedious. Just use what ever is best for the job. If you just need a light-weight API that is only ever going to be REST orientated, then use JSON. If you're building a very complex Enterprise SOA system, use XML as the associated technologies (xsd, xsl, soap+ws-* etc) will be very useful. If people are starting to invent XML like technologies for JSON (namespaces or schemas etc), then why not just use XML? It's already been done and works well.
- xyzzyz 16y agoIf you're building a very complex Enterprise SOA system, use XML as the associated technologies (xsd, xsl, soap+ws- etc) will be very useful.* What precisely are they useful for? Honest question, I have not had a job yet, let alone the "enterprise" one.
- goalieca 16y agoWell, same question here. I've interned on an enterprisey web service before but I couldn't imagine what sort of mental gymnastics are required to justify xml being used the way it is.
- MatthewPhillips 16y agoXSD is used to validate a document conforms to some standard. Say you run a legal document firm and you receive Form Foo from 100 different clients, XSD will handle validating that they are conforming to the standard for you. XSL is an umbrella for a few things, most interesting is XPath which is a super fast query language for xml documents. SOAP is just worthless. WSDL is nice though, it compiles a web service API to source code so you get a nice layer of abstraction around what you're writing to.
- mgkimsal 16y agoI've never seen WSDL used without SOAP. Not saying it couldn't happen, just not seen it. Do you ever use WSDL without SOAP? Or SOAP without WSDL?
- 16y ago
- njl 16y agoI think JSON's power comes from the fact that it is a subset of a programming language. I organize data in arrays and hash tables (or objects, which can be implemented as hash tables), and that is what JSON provides. I remember teaching classes in '99 where I needed to explain XML. I could do it in five minutes -- it's like HTML, but you get to make up tags that are case-sensitive. Every start tag needs to have an end tag, and attributes need to be quoted. Put this magic tag at the start, so parsers know it's XML. Here's the special case for a tag that closes itself. Then what happened? Validation, the gigantic stack of useless WS-* protocols, XSLT, SOAP, horrific parser interfaces, and a whole slew of enterprise-y technologies that cause more problems than they solve. Like COBRA, Ada, and every other "enterprise" technology that was specified first and implemented later, all of the XML add-ons are nice in theory but completely suck to use. XML has changed from a mildly verbose but eminently human-readable and machine-parsable data representation into a "technology" that has become over-specialized and covered with encrustations to the point that it is approaching regex's on the "now you have two problems" scale. JSON just gets back to a format that both the machine and I can read reliably and with ease.
- yuhong 16y agoOf course, you can still use plain old XML.
- mattmanser 16y agoSome languages are hostile to plain old XML too though, mix one namespace declaration with an XML novice and you'll end up with much head scratching as to how to actually get the data out. And then you have to add a few utterly pointless lines of code to deal with that namespace. And people defending XML namespaces will appear in 3, 2, 1... TBH at one point I thought the XML/XSLT combination for generating html server and clientside would be the next big thing, it was amazing for me, much, much better than jQuery.tmpl or any other js templating language as it acted identically on server/client. Unfortunately non-trivial XSLTs are a little much for many programmers to grok, you have to be able think functional. People want their loops. So I've given up on them as too high maintenance (even I had trouble reading xslts I'd written even a month ago). I do prefer json to xml now though.
- pdenya 16y agoI love APIs that offer JSON instead of XML. Especially when I'm programming in PHP, parsing XML is so tedious. On the other hand, using json_decode is a pleasure.
- code_duck 16y agoI can't stand PHP's DomDocument OR SimpleXML. I think it's mainly PHP's libraries at fault, though - I've made short work of tasks that were quite annoying in PHP using Beautiful Soup in Python.
- wvenable 16y agoPHP's DomDocument is pretty much the same as every other platform's DomDocument. Nearly the whole XML API universe is full of suck.
- trezor 16y agoThere are neat implementations out there. I particularly like C#'s LInQ for XML. Lets you shred that (untyped) XML into strongly typed objects faster than you can say "wow that's declarative". If you have a typed format (i.e. XSD), there are enough tools out there to generate the code <-> XML interchange boilerplate. In C#, this is typically solved by creating a serializable class with attributes/annotations denoting what XML nodes the actual class-properties map to. Again, fairly painless. And declarative. If your main beef with XML is that the libraries you have to work with is an exact replica of the W3C DOM-model, then it is your tooling which sucks. XML is just fine, when used correctly ofcourse. Think how jQuery managed to make writing JS fun, as opposed to when you had to work with the plain DOM. HTML is not that far from XML and if tooling can make that kind of difference, judging a technology exclusively based on your lacking libraries (or lack of exposure to good ones) can really not be considered fair by any means. Now with that said, I find JSON nice as well, but for different reasons and with different drawbacks.
- code_duck 16y ago> Think how jQuery managed to make writing JS fun, as opposed to when you had to work with the plain DOM. Speaking of that, http://code.google.com/p/phpquery/ http://code.google.com/p/phpquery/ is an interesting project. I haven't used it, but it seems like it could make some XML parsing less strenuous.
- bravura 16y agoIn case you are interested in fast, streaming parsing of JSON, check out the yajl library (http://softwaremaniacs.org/blog/2010/09/18/ijson/en/ http://softwaremaniacs.org/blog/2010/09/18/ijson/en/) In Python, I use the ijson bindings for yajl (http://softwaremaniacs.org/blog/2010/09/18/ijson/en/ http://softwaremaniacs.org/blog/2010/09/18/ijson/en/). Here is a blog post demonstrating ijson: http://thechangelog.com/post/1169335384/ijson-parse-streams-of-json-in-python http://thechangelog.com/post/1169335384/ijson-parse-streams-...
- jannes 16y agoBut still we are referring to the term AJAX, when we are in fact using AJAJ (what a name. I actually understand why nobody uses it).
- tzury 16y agoAside from wall of what was saying here, if you use JSON, you saved yourself from the attributes vs. elements discussions. Which is a net profit.
- santa_boy 16y agoJSON is extremely powerful and very light for well structured matrix /array like data objects. This is particularly useful for financial time series objects (asset prices, economics, etc). For example, in financial time series/ trading applications, see the following two charts, a data table and a visualization chart completely generated on the fly using JSON data inputs through ajax calls. Makes the application very light and all rendering is done on the client side. Market Returns Dashboard: http://bit.ly/iVxYoP http://bit.ly/iVxYoP Daily Market Commentary: http://bit.ly/my5A3c http://bit.ly/my5A3c
- deno 16y agoYou can just as well use XML. The XSD list data-type makes for great building block for structured arrays. For example: Schema: <xs:element name="series"> <xs:simpleType> <xs:list itemType="xs:double"/> </xs:simpleType> </xs:element> Document: <series>1.0 2.0 1.2 15.6 3.1 4.5 3.2</series>
- guelo 16y agoThe JSON/XML debate is very similar to the static/dynamic typing debate. The costs of static typing or XML don't seem worth it until a project starts getting bigger and you want to try to impose more organization and structure.
- joshontheweb 16y agoHave to say that I am surprised that only 20% of new apis are JSON. Seems like a shoe-in to me. Although, I use python and its perfect for that.
- aghilmort 16y agojson api http://correlate.googlelabs.com/search?e=json+api&t=weekly http://correlate.googlelabs.com/search?e=json+api&t=week... xml api http://correlate.googlelabs.com/search?e=xml+api&t=weekly http://correlate.googlelabs.com/search?e=xml+api&t=weekl...