Advertisement
Advertisement

新足迹

 找回密码
 注册
新足迹 门户 IT专业论坛 查看内容

ZT The rise of Json

2011-5-23 17:06| 发布者: | 查看: 3650| 原文链接

http://visitmix.com/writings/the-rise-of-json

I’ve been prototyping a new service, sketching out the different pieces: payload protocol, storage, data model, transport, client/server communication, etc.  And, upon completion of the prototype, I stepped back and looked at the decisions made. For example, how are we storing the data? Raw JSON.  How are we serving data? As JSON.
It suddenly struck me: there was never even a question of what format we would serialize to; JSON was assumed. And the idea that we would support XML as well as JSON wasn’t even considered.
The fact that this architecture was almost assumed instead of deliberated upon got me thinking: when was it that JSON won?  After all, the format isn’t that old. But its rise has been quick and triumphant.  I’m not the first one to observe this of course. There’s a great piece called “The Stealthy Ascendency of JSON” on DevCentral which does some digging across a range of available web APIs, discovering an increase in the percentage of APIs that support JSON as compared to XML in the last year.  The ProgrammableWeb has a piece called “JSON Continues its Winning Streak Over XML“ which similarly documents this trend. And there is also the much blogged about facts that Twitter has removed XML support from their streaming API and Foursquare’s v2 API only supports JSON.
All this begs a different question: Why is JSON so popular?  There is the simple fact that JSON is smaller as a payload than XML. And no doubt JSON is less verbose than XML.  But there’s much more to it than just size.  The crux has to do with programming.  JSON is natively tied to Javascript. As an object representation of data, it is so easy to work with inside Javascript. Its untyped nature flows perfectly with how Javascript itself works. Compare this to working with XML in Javascript: ugh.  There’s pretty fascinating piece by James Clark called “XML vs. The Web” that really dives into this.
JSON’s untyped nature flows with how the web itself works.  The web does not seem like typing; it doesn’t like schemas; it doesn’t like things to be rigid or too structured. Just look at the failure of XHTML.  A beautiful idea for the purists,  but for the web, its lack of adoption underscores its platonic ideals ........................

[ 本帖最后由 典 于 2011-5-23 18:49 编辑 ]
Advertisement
Advertisement


Advertisement
Advertisement
返回顶部