JSON It is never a good idea to mix syntax with semantics. Non è mai una buona idea di mescolare con sintassi semantica. When comparing Quando si confrontano JSON with con XML this is what first came to my mind. questo è ciò che è venuto prima a mio avviso. XML provides a syntactical as well as a semi-semantical layer for data transfer. XML fornisce una sintassi e una semi-semantical strato per il trasferimento dei dati. And that makes it a complicated choice. E che gli rende un complicato scelta. But that is just the tip of the proverbial iceberg. Ma che è solo la punta di un iceberg proverbiale. There is more to the story and at stake is the simple way of doing things. Non vi è di più per la storia e la posta in gioco è il modo semplice di fare le cose.

I am using JSON to communicate between Java backend (JSP, aren’t you shocked?) with, you guessed it, Javascript (Ext.js, in case you are curious). Sto usando JSON di comunicare tra backend Java (JSP, non si scandalizza?) Con, avete indovinato, Javascript (Ext.js, nel caso in cui siete curiosi). And I have to say, I am impressed by its simplicity. E devo dire, sono rimasto colpito dalla sua semplicità. I have used XML for several years, almost since it first started to get noticed as the sweet child of SGML, and being in the Java world XML becomes like your second language. Ho XML utilizzato per diversi anni, quasi quanto la prima volta per avere notato come il dolce bambino di SGML, e di essere nel mondo Java e XML diventa come la sua seconda lingua. And yet when I was forced to use JSON, I was floored by its simplicity and ease of use. E ancora quando sono stato costretto a utilizzare JSON, mi è stata pavimentata per la sua semplicità e facilità d'uso. In my book power with simplicity is the key property of a good software tool or technology. Nel mio libro di potenza con semplicità è la chiave di proprietà di un buon strumento software o tecnologia.

XML was simple to begin with. XML è stato semplice per cominciare. But then the Ma poi il semantics crowd semantica folla started to get involved. iniziato a partecipare. Soon XML devolved into the awful bloat of technology that it is today with all these namespace and URI. Presto devoluto in XML il terribile ingrossi di tecnologia che è oggi, con tutti questi nomi e URI.

Ode To JSON’s Simplicity Ode a JSON la semplicità
Parsing JSON documents is simple in whatever language you choose. JSON parsing dei documenti è semplice, in qualsiasi lingua scelta. Writing it is simpler and faster compared to XML. Scriverlo è più semplice e più veloce rispetto a XML. Personally I hate writing the < & >’s just to send a simple attribute or two across the wire. Personalmente Odio la scrittura <&> 's solo per inviare un semplice attributo o due in tutto il filo. Reading a JSON document is easier to the eye. JSON la lettura di un documento è più facile per gli occhi. JSON is also more compact than XML. JSON è anche più compatta di quella XML.

When transferring small data over the wire I would heartily recommend JSON to anyone who would listen. Quando il trasferimento di dati nel piccolo filo mi JSON consigliamo vivamente a tutti coloro che avrebbero ascoltare.

XML too has an enabling technology named Apache Axis. XML troppo ha un nome che consenta la tecnologia Apache Axis. If you had ever written simple web services with Apache Axis you will appreciate at its simplicity and power. Se si aveva mai scritto semplice con i servizi web Apache Axis potrete apprezzare nella sua semplicità e potenza. With such enabling technologies, think JDOM too, it can very much empower the users, there is not doubt. Con tali tecnologie abilitanti, JDOM pensare troppo, può autorizzare molto gli utenti, non c'è dubbio. However the default technologies that comes with XML are SAX (pronounced like Sucks) and DOM. Tuttavia l'impostazione predefinita tecnologie che viene fornito con XML sono SAX (si pronuncia come Sucks) e DOM. They are not at all fun to work with. Essi non sono affatto divertente con cui lavorare.

Zen and the Art of Data Transfer Zen e l'arte del trasferimento dei dati
Have you ever wondered why all the popular data transfer protocols are human readable? Ti sei mai chiesto perché tutti i popolare dei protocolli di trasferimento dati sono leggibile umano? Take as examples FTP, HTTP, SMTP, POP3 etc. even JSON and XML. Prendete come esempio FTP, HTTP, SMTP, POP3, ecc anche JSON e XML. There is a solid reason behind this. Non vi è una solida base di questo motivo. Data transfer is error prone and I am not just talking about the error introduced in the wire. Il trasferimento dei dati è soggetta a errore e non sto parlando solo l'errore introdotto nel filo. Modern protocols like TCP mostly take care of errors in the wire. Moderni protocolli TCP soprattutto come prendersi cura di errori nel filo. The challenge is in ensuring that you are transferring the data in proper format which is properly understood by the receiving party. La sfida consiste nel garantire che si stanno trasferendo i dati nel formato corretto che è ben compreso dalla parte ricevente. Mistakes are bound to happen. Errori sono tenuti ad accadere. A human readable protocol allows you to debug it easily and fix it. Un protocollo umano leggibile consente di eseguire il debug di esso facilmente e risolverlo.

Try reading a reasonable complex document (like genomic annotations) in XML and it will appear to you as mostly unreadable (or readable in a Matrix, the movie, kind of way). Provare la lettura di un documento complesso ragionevole (come genomica annotazioni) in XML e verrà visualizzato a voi come la maggior parte illeggibile (o leggibile in un Matrix, il film, tipo di strada). JSON on the other hand closely resembles the data structure which humans are comfortable to interpret. JSON dall'altro lato assomiglia da vicino la struttura di dati quali gli uomini sono comode da interpretare. In fact if I were explaining a data structure I would henceforth use JSON syntax. In realtà se fossi spiegare una struttura di dati che d'ora in poi utilizzare JSON sintassi.

I tried recently debugging huge amount of data I was sending over the wire in JSON. Ho provato di recente il debug di enormi quantità di dati mi è stato l'invio di oltre il filo in JSON. It took me a fraction of the time to debug it ( 5 minutes or less) than it would have taken me to debug an equivalent XML document. Mi ci sono voluti una frazione del tempo di eseguire il debug di esso (5 minuti o meno) di quello che avrebbe preso me di eseguire il debug di un equivalente documento XML. Human eyes, in my humble experience, do not adjust well to <'s and >’s. Occhi umani, a mio umile esperienza, non si adeguino bene a < 's e>' s. They confuse the hell out of my poor eyes. Essi confondono l'inferno fuori del mio povero occhi. If I were to compare it with program debugging I would say XML debugging is like using Borland C++ 4.5 (remember the switching between console and GUI mode with every line of instruction?) for debugging, whereas JSON debugging is like debugging with VC++ 2.0. Se dovessi confrontarlo con programma di debug vorrei dire XML è come il debug utilizzando Borland C + + 4.5 (ricordare la commutazione tra console e modalità GUI con ogni linea di insegnamento?) Per il debug, mentre JSON debug è come il debug con VC + + 2,0.

What about semantics? Per quanto riguarda la semantica?
As I said before don’t mix syntax with semantics. Come ho detto prima non miscelare con sintassi semantica. If you really wish to attach universally understandable semantics to your document then layer it on top of a simple syntactical layer like JSON. Se davvero si desidera allegare universalmente comprensibile semantica al documento poi strato è in cima a un semplice strato di sintassi come JSON. It will make both camps happy. Farà in modo che entrambi i campi felice. It will make for easier debugging. Questo renderebbe più facile per il debugging. It will also allow you to move your semantics to a different data transfer layer easily. Esso permetterà anche di spostare il tuo semantica di un diverso livello di trasferimento dati facilmente. Most of the time however the need for universality is in your head. La maggior parte del tempo però la necessità di universalità è in testa. Forcing semantics where it doesn’t need to be, forces you to adopt Costringendo la semantica in cui non ha bisogno di essere, le forze di adottare laughable semantics risibile semantica like foaf. come foaf.

The bottom line is that if you need to transfer some simple data then don’t waste your time over XML, use JSON. La linea di fondo è che se avete bisogno di trasferire alcuni semplici dati quindi non perdere il tuo tempo su XML, utilizzare JSON. You will be more effective as a developer and your boss will love (platonic I hope) you for it. Vi saranno più efficaci come sviluppatore e il tuo capo sarà amore (platonico spero) per aver scelto di esso.