Welcome!

XML Authors: Carmen Gonzalez, Ignacio M. Llorente, David Dossot, Yeshim Deniz, Elizabeth White

Related Topics: XML, AJAX & REA, Web 2.0

XML: Article

JSON vs XML - A Jason vs Freddie Sequel

It's not the latest sequel to the "Jason versus Freddie" movie, it's one of the decisions you need to make

(April 5, 2006) - It’s not the latest sequel to the “Jason versus Freddie” movie, it’s one of the decisions you need to make if you’re rolling out a Web 2.0 product. Make the wrong choice, and your project and reputation can suffer. Make the right choice, and you can be a hero. There aren’t any easy answers, but I can take you on a tour of the technology and the decisions involved so you can make a better-informed choice. During our tour I promise you won’t be attacked by a man in a hockey mask, so sit back and enjoy the ride.

On one side, we have the XML/XMLHttpRequest camp.  It uses the world-wide XML standard for data. It also involves using the XMLHttpRequest capabilities of most all browsers to retrieve information from a server. We use the XMLHttpRequest object to get XML from our server. So when we say XML in this article we really are talking about both the data format and the data transportation pattern: the two are tightly linked in this area. Due to security concerns, the server has to be in the same domain as the web page. We gotta own it. So if you’re viewing a page from www.bugscratch.com, you can get data from the server at bugscratch.com, but not at weasels.bugscratch.com or at weasels.com. To get around this limitation, you have to use a proxy server: clients hit your bugscratch.com server and then the server goes to the rest of the web and finds information to return to the client. Processing happens asynchronously – your users can continue browsing the page while your code goes off and fetches information. Nearly everybody is a big player in this arena, including Microsoft, IBM. If you can name a big software company, they’ve got an AJAX XML toolkit.

On the other side, we have the JSON camp. JSON stands for JavaScript Object Notation. JSON is a way of formatting information so that it is native JavaScript. It’s not associated with any kind of data transportation pattern. When your data comes back from the server, it’s already in a JavaScript object format. Many developers consider JSON easier to read than XML, although personally I find them both equally readable once you get used to them.

So how can you compare a data format with a data transportation system? Aren’t they two different things? Can’t you just send JSON inside your XML? And isn’t this all called AJAX anyway? AJAX stands for Asynchronous JavaScript and XML. Where’s JSON in that?

As they used to say in a show when I was a kid, “grasshopper, you have much to learn.”

First, you can just embed JSON in your XML and badda-bing, badda-boom, you got both technologies. But you can also send JSON directly from the server to your browser, without any XMLHttpRequest object. You ask the server for information, and it sends you pre-formed Javascript Objects ready for you to use. JavaScript is not just data – you can also put methods and all sorts of goodies in JSON format. Would you rather have XML or pre-formed JavaScript objects? It probably depends on what you want to do with them. At the lowest level, if you are taking the XML and applying XSLT to make XHTML, then XML is better. On the other hand, if you are making procedural decisions in your JavaScript based on objects and their values (or methods), then JSON has the edge.

The plot, however, thickens. Because JSON is transportation-independent, you can just bypass the XMLHttpRequest object for getting your data. Bypassing the XMLHttpRequest system is an interesting option that you may have not considered, and in my opinion it is the primary benefit of using JSON. The acronym AJAX doesn’t really work that well for this pattern, however. I suggest we call such systems XJAX systems, as I explain below.

Meanwhile back in the XML camp, one of the great benefits is that it seems like everybody is working over here. If you want to buy a package that does it all, you can find a lot to peruse. For most of us, we want something to take out of the box and start using, and the XML/XMLHttpRequest guys have it. And they have a lot of it. You can get big, full-featured, big functionality systems. Plus you’ve got a company to back you up in case of trouble. For the Microsoft fans, Atlas is rolling out. Infragistics is AJAX-enabling their suite. Even smaller companies like RicherComponents are stepping up to the AJAX plate in a big way. For you Linux folks, just name the big player and they’re there: IBM, Sun, Opera. And let’s face it: if you still want JSON, just stick it in the XML on the way back to the client. These are some powerful benefits for most consumers.

In addition, we’re not just talking toolkits operating at the lowest level. Some of these suites have fully formed tool groups that do all sorts of neat things for the client. It’s truly turn-key development: complete packages that snap right into your development environment.

XJAX, however, has a secret weapon in its toolkit which is as just as powerful. Since JSON is legal JavaScript, you can get it from anywhere. After all, you can’t very well have a world-wide web only running programs from one server, can you? Everything has to interoperate. When you put a Technorati link on your site, you’re running a bit of code from the Technorati site every time a user visits your site. Same goes for Google Analytics, or any of a zillion other examples.

So that means when you use JSON, you can get data from anywhere, not just your own domain. There’s no more proxy server nonsense. [Insert long argument about security here, which I will not cover for the sake of brevity] There is also a subtle change to the business model which might have a big impact. It means the old concept of server-based development is changing. Why’s that?

Most of these companies offering solutions are offering server-based solutions. That is, you install something on your server which then delivers JavaScript code to the client to make all the good stuff happen. (Yes, there are companies offering AJAX products on the web, but this is a development discussion, not a product discussion) The assumption is that companies sell toolkits to developers which then install it in their development/test/production system. Sales are made to folks who write stuff on the server. The products, for as much functionality as they provide on the client, are really just server products. All the instructions will be how to configure your server to use the tools, how to write programs on your server to make the client act in such-and-such a way, etc.

The world has changed. When I wrote my latest Web 2.0 application, it was a toolkit for bloggers. (shameless plug: visit batBack and check us out! It’s the coolest blogging toolbox on the web today!) If you were writing a blogging toolkit, the traditional way would be to write some server tools for a blogging engine, say MovableType and PHP, and then sell the toolkit to people who used the server tool MovableType.

But think about it – do I want to provide a product to folks who own a certain server, OS, and blogging system? Or am I providing a product for all bloggers to run on whatever blog they have? My customer is any blogger or reader – the world of blogging -- not people with a certain server system or browser. I am making solutions for a certain problem domain, not a certain technology domain. I want folks to add just one line of Javascript to their blogging template and have a complete blogging toolkit no matter which blogging engine or browser they are using. This is a major change and you should be aware that it is happening.

XJAX and JSON lets me do that. You can call it “serverless” programming. Users drop small pieces of JavaScript into their HTML to get big functionality. XJAX stands for X-domain JavaScript And XML (Yes, you can still send XML inside your JSON.) Sure, there is a server, but the server isn’t the key element in the food chain anymore. In fact, from the web developer’s standpoint, it’s just a minor player. You can take a server system that does one thing well – say deliver blog content to browsers, and add dozens of gadgets and whizbangs without having to be a server developer or being concerned about server tools or environment. Outsource the trivial commodities, grab the functionality for free, and concentrate on your goal and not the development details.The world has changed. If you’re a developer, Average Joe is taking your place, and the reign of the server is ending as we know it.

I don’t want to make this sound like a knock-out for JSON, because it’s not. I’m not aware of very many XJAX toolkits out there except for mine. Dave Johnson has some of these same ideas over at eBusiness Applications. Yahoo is also working in this area, and you should check out their JSON API.  It’s good to be in the lead, and this is one of those situations where the problems and technology come together in exactly the right way to catch on fire.

You should also consider that there is a lot of corporate development in which you own the browsers and you own the servers. You need to get up to speed and working right away. Having one vendor control all the processing on the browser is not a bad thing.  Who wants to go through brutal low-level Javascript coding if they don’t have to? (Trust me, you don’t.) For those shops (who are the majority) I would say find a good AJAX company and product and enjoy.

JSON has benefits too, as we’ve shown. If you’re doing something a little more free-form, if you’re looking to push the envelope of what’s possible, then I would go the JSON route. Whatever your choice, be aware that having preformed JavaScript delivered to your browser, as Martha Stewart would say, is a good thing. In the duke-out between JSON and XML there may be no knockouts, but there are a lot of points scored by both sides.

Some of the technologies mentioned here may be covered by intellectual property law. You should contact the author if you have further questions.

More Stories By Daniel B. Markham

Daniel Markham is a hands-on software architect who over the past several years has become a RUP mentor and Technology Strategist. Programming in all major languages and database platforms, his clients include Pitney Bowes, Ford, Charles Schwab, and the Department Of Defense. Daniel is the Principal Partner of Bedford Technology Group located in SW Virginia. He is the inventor of the only online multi-standard process evaluation system (www.MarkhamAssessmentTool.com) He is currently developing a free toolkit for bloggers using Web 2.0 technologies. batBack installs in seconds and requires no programming skills or special server configuration. It runs on all major blogging engines and browsers. It's also fully skinnable and extendable. You can find more about the batBack blog toolkit system at www.batBack.net You can reach Daniel at [email protected]

Comments (10) View Comments

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.


Most Recent Comments
tom mcdonald 04/17/08 07:25:51 AM EDT

this doesn't make sense. I'm a ajax developer and so might be biased against xjax, but at the very least I should be able to understand what you are talking about.

You talk about serverless development, but w/o a server you have no place to house your proprietary content. The serverless example you give is blog content, but if I'm hosting a site and the blog feature goes down then I get the tix (not some xjax provider). Worse, what if xjax provider loses my data.

It seems your prognostication doesn't stand up to my simple reality tests and thus I must not be getting it because you seem like a smart person and I would assume you apply the laugh rule.

Web 2.0 News Desk 12/26/06 12:15:08 PM EST

It's not the latest sequel to the 'Jason versus Freddie' movie, it's one of the decisions you need to make if you're rolling out a Web 2.0 product. Make the wrong choice, and your project and reputation can suffer. Make the right choice, and you can be a hero. There aren't any easy answers, but I can take you on a tour of the technology and the decisions involved so you can make a better-informed choice. During our tour I promise you won?t be attacked by a man in a hockey mask, so sit back and enjoy the ride.

Dave Webster 05/26/06 06:58:29 AM EDT

Interesting to see a lot of JavaScript/ECMAScript being used for these Web 2.0 applications. I guess, with the current climate of stable browsers and adoption of AJAX, we can think seriously now about engineering serious client-side scripts.

Rafik kafel 04/12/06 02:43:39 PM EDT

Don't you think "Asynchronous Javascript And XML" is a misnomer for a methodology/framework that is based on extensions?

I propose "Asynchronous Javascript Application eXtensions" instead.

Any thoughts?

Thanks

Rafik kafel 04/12/06 02:43:30 PM EDT

Don't you think "Asynchronous Javascript And XML" is a misnomer for a methodology/framework that is based on extensions?

I propose "Asynchronous Javascript Application eXtensions" instead.

Any thoughts?

Thanks

Rafik kafel 04/12/06 02:41:46 PM EDT

Don't you think "Asynchronous Javascript And XML" is a misnomer for a methodology/framework that is based on extensions?

I propose "Asynchronous Javascript Application eXtensions" instead.

Any thoughts?

Thanks

Mike Goldwater 04/12/06 05:27:48 AM EDT

Hi,
You are sending out your hitherto very interesting newsletter in an illegible font. Although we baby boomers are are still very much active our eye-sight might no longer be 20/20. Please consider all your potetial audience and use a larger font.

Thank you,

R Martin Ladner 04/11/06 10:10:39 AM EDT

Where do I learn more? You have my attention. Now how do I use use JSON, where can I find examples, and how does XJAX (mentioned in your earlier article) avoid crippling cross-domain blocks? =Marty=

xjax 04/07/06 07:20:08 AM EDT

So that X stands then for the cross (x) in "cross-domnain" is that it?

SYS-CON Brazil News Desk 04/05/06 08:16:59 PM EDT

It's not the latest sequel to the 'Jason versus Freddie' movie, it's one of the decisions you need to make if you're rolling out a Web 2.0 product. Make the wrong choice, and your project and reputation can suffer. Make the right choice, and you can be a hero. There aren't any easy answers, but I can take you on a tour of the technology and the decisions involved so you can make a better-informed choice. During our tour I promise you won?t be attacked by a man in a hockey mask, so sit back and enjoy the ride.

@ThingsExpo Stories
Cultural, regulatory, environmental, political and economic (CREPE) conditions over the past decade are creating cross-industry solution spaces that require processes and technologies from both the Internet of Things (IoT), and Data Management and Analytics (DMA). These solution spaces are evolving into Sensor Analytics Ecosystems (SAE) that represent significant new opportunities for organizations of all types. Public Utilities throughout the world, providing electricity, natural gas and water, are pursuing SmartGrid initiatives that represent one of the more mature examples of SAE. We have s...
The security devil is always in the details of the attack: the ones you've endured, the ones you prepare yourself to fend off, and the ones that, you fear, will catch you completely unaware and defenseless. The Internet of Things (IoT) is nothing if not an endless proliferation of details. It's the vision of a world in which continuous Internet connectivity and addressability is embedded into a growing range of human artifacts, into the natural world, and even into our smartphones, appliances, and physical persons. In the IoT vision, every new "thing" - sensor, actuator, data source, data con...
How do APIs and IoT relate? The answer is not as simple as merely adding an API on top of a dumb device, but rather about understanding the architectural patterns for implementing an IoT fabric. There are typically two or three trends: Exposing the device to a management framework Exposing that management framework to a business centric logic Exposing that business layer and data to end users. This last trend is the IoT stack, which involves a new shift in the separation of what stuff happens, where data lives and where the interface lies. For instance, it's a mix of architectural styles ...
The 3rd International Internet of @ThingsExpo, co-located with the 16th International Cloud Expo - to be held June 9-11, 2015, at the Javits Center in New York City, NY - announces that its Call for Papers is now open. The Internet of Things (IoT) is the biggest idea since the creation of the Worldwide Web more than 20 years ago.
The Internet of Things is tied together with a thin strand that is known as time. Coincidentally, at the core of nearly all data analytics is a timestamp. When working with time series data there are a few core principles that everyone should consider, especially across datasets where time is the common boundary. In his session at Internet of @ThingsExpo, Jim Scott, Director of Enterprise Strategy & Architecture at MapR Technologies, discussed single-value, geo-spatial, and log time series data. By focusing on enterprise applications and the data center, he will use OpenTSDB as an example t...
An entirely new security model is needed for the Internet of Things, or is it? Can we save some old and tested controls for this new and different environment? In his session at @ThingsExpo, New York's at the Javits Center, Davi Ottenheimer, EMC Senior Director of Trust, reviewed hands-on lessons with IoT devices and reveal a new risk balance you might not expect. Davi Ottenheimer, EMC Senior Director of Trust, has more than nineteen years' experience managing global security operations and assessments, including a decade of leading incident response and digital forensics. He is co-author of t...
The Internet of Things will greatly expand the opportunities for data collection and new business models driven off of that data. In her session at @ThingsExpo, Esmeralda Swartz, CMO of MetraTech, discussed how for this to be effective you not only need to have infrastructure and operational models capable of utilizing this new phenomenon, but increasingly service providers will need to convince a skeptical public to participate. Get ready to show them the money!
The Internet of Things will put IT to its ultimate test by creating infinite new opportunities to digitize products and services, generate and analyze new data to improve customer satisfaction, and discover new ways to gain a competitive advantage across nearly every industry. In order to help corporate business units to capitalize on the rapidly evolving IoT opportunities, IT must stand up to a new set of challenges. In his session at @ThingsExpo, Jeff Kaplan, Managing Director of THINKstrategies, will examine why IT must finally fulfill its role in support of its SBUs or face a new round of...
One of the biggest challenges when developing connected devices is identifying user value and delivering it through successful user experiences. In his session at Internet of @ThingsExpo, Mike Kuniavsky, Principal Scientist, Innovation Services at PARC, described an IoT-specific approach to user experience design that combines approaches from interaction design, industrial design and service design to create experiences that go beyond simple connected gadgets to create lasting, multi-device experiences grounded in people's real needs and desires.
Enthusiasm for the Internet of Things has reached an all-time high. In 2013 alone, venture capitalists spent more than $1 billion dollars investing in the IoT space. With "smart" appliances and devices, IoT covers wearable smart devices, cloud services to hardware companies. Nest, a Google company, detects temperatures inside homes and automatically adjusts it by tracking its user's habit. These technologies are quickly developing and with it come challenges such as bridging infrastructure gaps, abiding by privacy concerns and making the concept a reality. These challenges can't be addressed w...
The Domain Name Service (DNS) is one of the most important components in networking infrastructure, enabling users and services to access applications by translating URLs (names) into IP addresses (numbers). Because every icon and URL and all embedded content on a website requires a DNS lookup loading complex sites necessitates hundreds of DNS queries. In addition, as more internet-enabled ‘Things' get connected, people will rely on DNS to name and find their fridges, toasters and toilets. According to a recent IDG Research Services Survey this rate of traffic will only grow. What's driving t...
Connected devices and the Internet of Things are getting significant momentum in 2014. In his session at Internet of @ThingsExpo, Jim Hunter, Chief Scientist & Technology Evangelist at Greenwave Systems, examined three key elements that together will drive mass adoption of the IoT before the end of 2015. The first element is the recent advent of robust open source protocols (like AllJoyn and WebRTC) that facilitate M2M communication. The second is broad availability of flexible, cost-effective storage designed to handle the massive surge in back-end data in a world where timely analytics is e...
Scott Jenson leads a project called The Physical Web within the Chrome team at Google. Project members are working to take the scalability and openness of the web and use it to talk to the exponentially exploding range of smart devices. Nearly every company today working on the IoT comes up with the same basic solution: use my server and you'll be fine. But if we really believe there will be trillions of these devices, that just can't scale. We need a system that is open a scalable and by using the URL as a basic building block, we open this up and get the same resilience that the web enjoys.
We are reaching the end of the beginning with WebRTC, and real systems using this technology have begun to appear. One challenge that faces every WebRTC deployment (in some form or another) is identity management. For example, if you have an existing service – possibly built on a variety of different PaaS/SaaS offerings – and you want to add real-time communications you are faced with a challenge relating to user management, authentication, authorization, and validation. Service providers will want to use their existing identities, but these will have credentials already that are (hopefully) i...
"Matrix is an ambitious open standard and implementation that's set up to break down the fragmentation problems that exist in IP messaging and VoIP communication," explained John Woolf, Technical Evangelist at Matrix, in this SYS-CON.tv interview at @ThingsExpo, held Nov 4–6, 2014, at the Santa Clara Convention Center in Santa Clara, CA.
P2P RTC will impact the landscape of communications, shifting from traditional telephony style communications models to OTT (Over-The-Top) cloud assisted & PaaS (Platform as a Service) communication services. The P2P shift will impact many areas of our lives, from mobile communication, human interactive web services, RTC and telephony infrastructure, user federation, security and privacy implications, business costs, and scalability. In his session at @ThingsExpo, Robin Raymond, Chief Architect at Hookflash, will walk through the shifting landscape of traditional telephone and voice services ...
Explosive growth in connected devices. Enormous amounts of data for collection and analysis. Critical use of data for split-second decision making and actionable information. All three are factors in making the Internet of Things a reality. Yet, any one factor would have an IT organization pondering its infrastructure strategy. How should your organization enhance its IT framework to enable an Internet of Things implementation? In his session at Internet of @ThingsExpo, James Kirkland, Chief Architect for the Internet of Things and Intelligent Systems at Red Hat, described how to revolutioniz...
Bit6 today issued a challenge to the technology community implementing Web Real Time Communication (WebRTC). To leap beyond WebRTC’s significant limitations and fully leverage its underlying value to accelerate innovation, application developers need to consider the entire communications ecosystem.
The definition of IoT is not new, in fact it’s been around for over a decade. What has changed is the public's awareness that the technology we use on a daily basis has caught up on the vision of an always on, always connected world. If you look into the details of what comprises the IoT, you’ll see that it includes everything from cloud computing, Big Data analytics, “Things,” Web communication, applications, network, storage, etc. It is essentially including everything connected online from hardware to software, or as we like to say, it’s an Internet of many different things. The difference ...
Cloud Expo 2014 TV commercials will feature @ThingsExpo, which was launched in June, 2014 at New York City's Javits Center as the largest 'Internet of Things' event in the world.