Вы находитесь на странице: 1из 5

24-02-2010 JSON Pros and Cons « MyArch

subscribe to RSS feed

Home
Build and Deployment Automation
Open-Source Projects
Blog
About Us

JSO Pros and Cons


Posted on 02/08/2007 , Alexander Ananiev, 7 Comments ( Add )

JSON is a simple object serialization approach based on the JavaScript object initializers syntax. The code
for initializer (object literal) is put into a string and then interpreted using JavaScript eval() function or JSON
parser (which is very lightweight):

serializedObj='{firstName:"john", lastName:"doe"}';
...
// This is just an example, JSON parser should be used instead
// to avoid security vulnerabilities of "eval"
var obj = eval("(" + serializedObj + ")");
document.getElementById("firstName").innerHTML=person.firstName;

JSON is used extensively in various AJAX frameworks and toolkits to provide easy object serialization for
remote calls. It is is supported by both GWT and DOJO. There is a growing realization that perhaps JSON
should be considered as an option when implementing SOA, for example Dion Hinchcliffe recently published
a blog entry suggesting that JSON (and other Web 2.0 technologies) must be seriously considered by SOA
architects.

So what are the benefits of using JSON relative to XML (for this comparison I want to focus just on XML
and stay away from SOAP)? Here is my brief take on that, there are also numerous other articles and posts
on the subjects.

JSO XML
JSON strengths
Fully automated way of de-serializing/serializing Developers have to write JavaScript code to
JavaScript objects, minimum to no coding serialize/de-serialize to/from XML
While XML parsers are built-in into all modern
Very good support by all browsers browsers, cross-browser XML parsing can be
tricky, e.g., see this article
Concise format thanks to name/value pair -based
Verbose format because of tags and namespaces
approach
Fast object de-serialization in JavaScript (based on Slower de-serialization in JavaScript (based on
anecdotal evidence ) anecdotal evidence )
Supported by many AJAX toolkits and JavaScript
Not very well supported by AJAX toolkits
libraries
Simple API (available for JavaScript and many other
More complex APIs
languages)
JSON weaknesses
No support for formal grammar definition, hence
XML Schema or DTD can be used to define
interface contracts are hard to communicate and
grammars
enforce

http://myarch.com/json-pros-and-cons 1/5
24-02-2010 JSON Pros and Cons « MyArch
Good namespace support, many different extensibility
No namespace support, hence poor extensibility
options in Schema
Supported by wide array of development and other
Limited development tools support
(e.g., transformation) tools
Narrow focus, used for RPC only, primarily with
Broad focus - can be used for RPC, EDI, metadata,
JavaScript clients (although one can argue that it's
you name it
one of the strengths)
No support in Web services -related products
Supported by all Web services products
(application servers, ESBs, etc), at least not yet

So the bottom line is that JSON and XML are, of course, two very different technologies; XML is much
broader in scope so I'm not even sure if comparing them side by side is fair.

As an object serialization technology for AJAX (or should it now be called AJAJ since we've replaced XML
with JSON?) JSON looks very appealing. Anybody who ever tried parsing SOAP directly in a browser
(while having to support multiple browsers) can attest that this is not a straightforward task. JSON simplifies
this task dramatically. So I think that ESB vendors should definitely start thinking about adding JSON to the
list of formats they support.

One of the keys to SOA success is that it should be easy to consume a service, i.e., the entry barrier for
service consumers must be low to support "grass root" SOA adoption. While a top-down SOA effort may
succeed, it will certainly take longer than bottom-up ("grass-root") approach when developers are able to
consume services as they see fit. AJAX/JSON fits this bill perfectly - it is easily understood by developers
and it does not require any Web services -specific tools or infrastructure.

So overall I'm pretty enthusiastic about JSON.

This entry was posted on Thursday, February 8th, 2007 at 11:51 pm and is filed under SOA, Web services,
XML. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or
trackback from your own site.

7 Responses to “JSO Pros and Cons”


#4624 | February 13th, 2007 | nhm tanveer hossain khan (hasan)

JSON is promising, comparing xml or more complex xml content like soap, json saves a lot of processing
pressure. it is a great recuse for the visitor.

#4643 | February 14th, 2007 | Hans

I’ve been wondering about what acronym should be used for “Asynchronous JavaScript and JSON”. But if
you write it all out you get “Asynchronous JavaScript and JavaScript Object Notation”, so “JavaScript” is
redundant and the phrase can be shortened to “Asynchronous JavaScript Object Notation”. AJON?

Thanks for the writeup!

#4650 | February 15th, 2007 | Raymond

The comparison gave the impression that JSON can only be used with Javascript.
According the author, he defined JSON using javascript but it is a standard that is not confined to Javascript.
It is “…a” text format that is completely language independent.”

Go to http://www.JSON.org and read about JSON. Also there are links that answers some of the issues
raised in this article.

I am not for or against JSON. XML and JSON both has their own merits. A good developer will pick the
best to use for the situation.

#4658 | February 15th, 2007 | Alexander Ananiev

Raymond:
JSON is indeed language independent, however, the balance shifts when you are not using JavaScript – most

http://myarch.com/json-pros-and-cons 2/5
24-02-2010 JSON Pros and Cons « MyArch
other languages have very good Web services and XML support, so I’m not sure what would be the use
case for JSON, say, in .NET or Java environment. It’s the lack of good XML support in browsers that
makes JSON so appealing IMO.

#6020 | April 1st, 2007 | » JSON Web Services – the XML JSON debate further ahead TechTracer:
Tracing the course of technology

[...] JSON- Some Facts Coming back to JSON, the main fact which goes against JSON is it is not
standardized. But now if JSON wants to establish its presence then the only field in my opinion would be
SOA web services and AJAX where, it has received a lot of attention. Lately the debate on using web
services with JSON has started. XML being heavy puts somewhat a hindrance on the acceptance of web
services since the network infrastructure needs to get upgraded to get quicker adoption of XML RPC web
services. With JSON, if web services give a higher throughput then it might be time to cash upon its
acceptance for data transfer. Alexander writes about JSON pros and cons in his blog MyArch, One of the
keys to SOA success is that it should be easy to consume a service, i.e., the entry barrier for service
consumers must be low to support “grass root” SOA adoption. While a top-down SOA effort may succeed,
it will certainly take longer than bottom-up (”grass-root”) approach when developers are able to consume
services as they see fit. AJAX/JSON fits this bill perfectly – it is easily understood by developers and it does
not require any Web services -specific tools or infrastructure.So overall I’m pretty enthusiastic about JSON.
[...]

#24355 | March 10th, 2008 | Sharath

Does Json webservice allow List or arrays having more elements within them as members of a return type
List

#34814 | December 18th, 2008 | Prashant Joshi

Every technology has its own merits and de-merits. As per my experience, JSON is good for sending small
information over http. when use along with REST, it offers lots of flexibility, specially when working in cross
technology domain.

Leave a Reply
Name

Mail

Website

Your Comment

Most Popular Posts


Why XML is Bad for Humans
Ant Scripts without XML
Instantly Redeploy Your Classes
Reliability of SOAP over HTTP Web Services
JSON Pros and Cons

Recent Tweets
http://myarch.com/json-pros-and-cons 3/5
Recent Tweets
24-02-2010 JSON Pros and Cons « MyArch

On the builder pattern: http://is.gd/8XSxr I wonder, why is it mostly Java developers who are
obsessed with design patterns? 1 day ago
Rackspace: 56,671 servers shows an upward trend over the past four quarters from $2,899 to $2,991
per server: http://is.gd/8XRPm 1 day ago
Iceland is being touted as DataCenter mecca: average daily high in July is 56, electricity cost >2 times
less than US - http://is.gd/8Tpmc 2 days ago
Good post about how Tomcat self-support caused significant loss at one company. Support is never
free, that's for sure: http://is.gd/8K8Zm 4 days ago
More updates...

Recent Posts
WebSphere Adminstration: Getting Started with WebSphere Application Server Scripting
WebSphere Administration: Using Thin Administration Client
ClassNotFoundException: A List of Dumb Things to Check
Automating Your Builds? Don’t Forget About Testing
PAnt Documentation Has Been Updated
How to Get Started with PAnt
Creating Ant Targets in Python with PAnt 2.0
PAnt 1.5 is Released
Eliminate the Need to Redeploy Your Web Files
Instantly Redeploy Your Classes to WebSphere Application Server
WebSphere Administration: Setting Heap Size
Ant Task without Setters

Blog Categories
Ant (9)
BPEL (4)
Building software (20)
Developer productivity (2)
Dynamic languages (2)
ESB (10)
IT operations (4)
JAX-WS (2)
PAnt (7)
SCA (3)
SOA (29)
SOA Appliances (1)
Troubleshooting (1)
Uncategorized (1)
Web services (27)
Web Services Registry (1)
WebSphere (16)
WebSphere Application Server Administration (13)
XML (8)
XML Appliances (4)
XML Schema (1)

Blog Archives
February 2010
January 2010
December 2009
November 2009
July 2009
May 2009
April 2009
March 2009
http://myarch.com/json-pros-and-cons 4/5
24-02-2010 JSON Pros and Cons « MyArch
February 2009
January 2009
December 2008
November 2008

Home
Build and Deployment Automation
Open-Source Projects
Blog
About Us

http://myarch.com/json-pros-and-cons 5/5

Вам также может понравиться