Welcome!

XML Authors: Sandi Mappic, Esmeralda Swartz, Carmen Gonzalez, Pat Romanski, Liz McMillan

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)

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.


@ThingsExpo Stories
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 Internet of @ThingsExpo, Esmeralda Swartz, CMO of MetraTech, will discuss 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! Speaker Bio: Esmeralda Swartz, CMO of MetraTech, has spent 16 years as a marketing, product management, and busin...
Samsung VP Jacopo Lenzi, who headed the company's recent SmartThings acquisition under the auspices of Samsung's Open Innovaction Center (OIC), answered a few questions we had about the deal. This interview was in conjunction with our interview with SmartThings CEO Alex Hawkinson. IoT Journal: SmartThings was developed in an open, standards-agnostic platform, and will now be part of Samsung's Open Innovation Center. Can you elaborate on your commitment to keep the platform open? Jacopo Lenzi: Samsung recognizes that true, accelerated innovation cannot be driven from one source, but requires a...
SYS-CON Events announced today that Red Hat, the world's leading provider of open source solutions, will exhibit at Internet of @ThingsExpo, which will take place on November 4–6, 2014, at the Santa Clara Convention Center in Santa Clara, CA. Red Hat is the world's leading provider of open source software solutions, using a community-powered approach to reliable and high-performing cloud, Linux, middleware, storage and virtualization technologies. Red Hat also offers award-winning support, training, and consulting services. As the connective hub in a global network of enterprises, partners, a...
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 Internet of @ThingsExpo, Robin Raymond, Chief Architect at Hookflash Inc., will walk through the shifting landscape of traditional telephone a...
SYS-CON Events announced today that Matrix.org has been named “Silver Sponsor” of Internet of @ThingsExpo, which will take place on November 4–6, 2014, at the Santa Clara Convention Center in Santa Clara, CA. Matrix is an ambitious new open standard for open, distributed, real-time communication over IP. It defines a new approach for interoperable Instant Messaging and VoIP based on pragmatic HTTP APIs and WebRTC, and provides open source reference implementations to showcase and bootstrap the new standard. Our focus is on simplicity, security, and supporting the fullest feature set.
BSQUARE is a global leader of embedded software solutions. We enable smart connected systems at the device level and beyond that millions use every day and provide actionable data solutions for the growing Internet of Things (IoT) market. We empower our world-class customers with our products, services and solutions to achieve innovation and success. For more information, visit www.bsquare.com.
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 style...
SYS-CON Events announced today that SOA Software, an API management leader, will exhibit at SYS-CON's 15th International Cloud Expo®, which will take place on November 4–6, 2014, at the Santa Clara Convention Center in Santa Clara, CA. SOA Software is a leading provider of API Management and SOA Governance products that equip business to deliver APIs and SOA together to drive their company to meet its business strategy quickly and effectively. SOA Software’s technology helps businesses to accelerate their digital channels with APIs, drive partner adoption, monetize their assets, and achieve a...
From a software development perspective IoT is about programming "things," about connecting them with each other or integrating them with existing applications. In his session at @ThingsExpo, Yakov Fain, co-founder of Farata Systems and SuranceBay, will show you how small IoT-enabled devices from multiple manufacturers can be integrated into the workflow of an enterprise application. This is a practical demo of building a framework and components in HTML/Java/Mobile technologies to serve as a platform that can integrate new devices as they become available on the market.
SYS-CON Events announced today that Utimaco will exhibit at SYS-CON's 15th International Cloud Expo®, which will take place on November 4–6, 2014, at the Santa Clara Convention Center in Santa Clara, CA. Utimaco is a leading manufacturer of hardware based security solutions that provide the root of trust to keep cryptographic keys safe, secure critical digital infrastructures and protect high value data assets. Only Utimaco delivers a general-purpose hardware security module (HSM) as a customizable platform to easily integrate into existing software solutions, embed business logic and build s...
Connected devices are changing the way we go about our everyday life, from wearables to driverless cars, to smart grids and entire industries revolutionizing business opportunities through smart objects, capable of two-way communication. But what happens when objects are given an IP-address, and we rely on that connection, sometimes with our lives? How do we secure those vast data infrastructures and safe-keep the privacy of sensitive information? This session will outline how each and every connected device can uphold a core root of trust via a unique cryptographic signature – a “bir...
Internet of @ThingsExpo Silicon Valley announced on Thursday its first 12 all-star speakers and sessions for its upcoming event, which will take place November 4-6, 2014, at the Santa Clara Convention Center in California. @ThingsExpo, the first and largest IoT event in the world, debuted at the Javits Center in New York City in June 10-12, 2014 with over 6,000 delegates attending the conference. Among the first 12 announced world class speakers, IBM will present two highly popular IoT sessions, which will take place November 4-6, 2014 at the Santa Clara Convention Center in Santa Clara, Calif...
Almost everyone sees the potential of Internet of Things but how can businesses truly unlock that potential. The key will be in the ability to discover business insight in the midst of an ocean of Big Data generated from billions of embedded devices via Systems of Discover. Businesses will also need to ensure that they can sustain that insight by leveraging the cloud for global reach, scale and elasticity.
WebRTC defines no default signaling protocol, causing fragmentation between WebRTC silos. SIP and XMPP provide possibilities, but come with considerable complexity and are not designed for use in a web environment. In his session at Internet of @ThingsExpo, Matthew Hodgson, technical co-founder of the Matrix.org, will discuss how Matrix is a new non-profit Open Source Project that defines both a new HTTP-based standard for VoIP & IM signaling and provides reference implementations.

SUNNYVALE, Calif., Oct. 20, 2014 /PRNewswire/ -- Spansion Inc. (NYSE: CODE), a global leader in embedded systems, today added 96 new products to the Spansion® FM4 Family of flexible microcontrollers (MCUs). Based on the ARM® Cortex®-M4F core, the new MCUs boast a 200 MHz operating frequency and support a diverse set of on-chip peripherals for enhanced human machine interfaces (HMIs) and machine-to-machine (M2M) communications. The rich set of periphera...

SYS-CON Events announced today that Aria Systems, the recurring revenue expert, has been named "Bronze Sponsor" of SYS-CON's 15th International Cloud Expo®, which will take place on November 4-6, 2014, at the Santa Clara Convention Center in Santa Clara, CA. Aria Systems helps leading businesses connect their customers with the products and services they love. Industry leaders like Pitney Bowes, Experian, AAA NCNU, VMware, HootSuite and many others choose Aria to power their recurring revenue business and deliver exceptional experiences to their customers.
The Internet of Things (IoT) is going to require a new way of thinking and of developing software for speed, security and innovation. This requires IT leaders to balance business as usual while anticipating for the next market and technology trends. Cloud provides the right IT asset portfolio to help today’s IT leaders manage the old and prepare for the new. Today the cloud conversation is evolving from private and public to hybrid. This session will provide use cases and insights to reinforce the value of the network in helping organizations to maximize their company’s cloud experience.
The Internet of Things (IoT) is making everything it touches smarter – smart devices, smart cars and smart cities. And lucky us, we’re just beginning to reap the benefits as we work toward a networked society. However, this technology-driven innovation is impacting more than just individuals. The IoT has an environmental impact as well, which brings us to the theme of this month’s #IoTuesday Twitter chat. The ability to remove inefficiencies through connected objects is driving change throughout every sector, including waste management. BigBelly Solar, located just outside of Boston, is trans...
SYS-CON Events announced today that Matrix.org has been named “Silver Sponsor” of Internet of @ThingsExpo, which will take place on November 4–6, 2014, at the Santa Clara Convention Center in Santa Clara, CA. Matrix is an ambitious new open standard for open, distributed, real-time communication over IP. It defines a new approach for interoperable Instant Messaging and VoIP based on pragmatic HTTP APIs and WebRTC, and provides open source reference implementations to showcase and bootstrap the new standard. Our focus is on simplicity, security, and supporting the fullest feature set.
Predicted by Gartner to add $1.9 trillion to the global economy by 2020, the Internet of Everything (IoE) is based on the idea that devices, systems and services will connect in simple, transparent ways, enabling seamless interactions among devices across brands and sectors. As this vision unfolds, it is clear that no single company can accomplish the level of interoperability required to support the horizontal aspects of the IoE. The AllSeen Alliance, announced in December 2013, was formed with the goal to advance IoE adoption and innovation in the connected home, healthcare, education, aut...