Select the directory option from the above "Directory" header!

JSON data interchange format gets standards blessing

JSON data interchange format gets standards blessing

Ecma approves the format, which offers an alternative to XML

An up-and-coming lightweight data interchange format for Web applications, considered by a growing number of people to be an alternative to XML, has gotten a boost from the standards body Ecma.

The Ecma General Assembly has approved the fifth edition of ECMAScript (PDF), according to Istvan Sebestyen, secretary general of the organization. Included in this new version of ECMAScript, of which the popular JavaScript is a dialect, is native support for using JavaScript Object Notation (JSON).

This inclusion "will certainly have a big impact on developers," said Douglas Crockford, the Yahoo software architect cited as the creator of JSON.

"JSON is already pretty widely-used in Web applications. By having JSON built into the ECMAScript language, [JSON] implementations will get faster and safer," Crockford said.

The approval is also a sign that the Web application development community is edging away from using XML as the sole desired standard for exchanging data among disparate systems, in at least those cases where delivery of relatively simple structured data is required.

The new standard, officially entitled ECMA-262, includes an object for both creating and parsing JSON texts. For the most part, it follows the 2006 Internet Engineering Task Force RFC 4627 authored by Crockford.

The new ECMAScript standard attempts to rectify a number of security issues surrounding JSON.

Over the past several years, a growing number of Web application developers used JSON instead of XML-based approaches, like the Simple Object Access Protocol, to mark up data so it can be transferred between two computers. This created two sometimes-opposing camps within the Web application development community.

"The split between the JSON and XML advocates is strong and will continue for the foreseeable future," said Daniel Markham, an Ajax architect and principal partner of the Virginia-based consulting firm Bedford Technology Group.

Advocates have praised JSON for its simplicity. According to the RFC, JSON was specifically developed to handle "the serialization of structured data." JSON is a set of conventions, or a grammar, on how to order the data to be transmitted so it can be parsed by the recipient. It borrows JavaScript's rules for formatting objects and arrays.

In contrast, XML relies on schema-based markup tags, which tend to make the datasets larger and more complex than those typically rendered in JSON.

"I'm an overall fan of JSON over XML, mainly because XML has a lot of syntactic fluff you have to dig through to get anything useful out of it. There's just an extra cognitive load that you don't have if your JavaScript objects match up closely with your server entities," Markham said.

Markham also noted that XML has a flexibility that JSON can't match. "XML remains the Swiss Army knife of the Internet: able to handle all sorts of data from any connector," he said.

Crockford formulated JSON in 2001 when working on a number of Web applications using the Ajax set of web development tools, which includes JavaScript, XML and HTML. He found XML to be too bulky for his needs.

"XML was just inexcusably ugly and inefficient, and so we came up with using JavaScript's own data representation to represent the data," Crockford said. Crockford is widely cited as being the inventor of JSON, though he is modest about assuming this appellative. "It already existed in nature. I just discovered it," he said.

Since its creation in 2001, JSON has grown in popularity. The site lists a number JSON converters for languages such as Perl, Active Server Pages, PHP, C, Java, Python and others. Yahoo supports JSON for its Web services.

The latest versions of Internet Explorer and Firefox both have JSON support. JSON "looks like it will be the first bit of ECMAScript 5 that will be rolled out universally," Crockford said.

JSON itself has always been a part of ECMAScript, at least insofar as Crockford used ECMAScript grammar as the basis for JSON. The difference with ECMAScript 5, Crockford noted, is that ECMAScript has "built-in library support" for JSON. This will help in matters of security.

Most developers used the JavaScript eval() function to parse JSON-based text into usable data structures. Security professionals see this approach as a security flaw, because this form of input could allow third-parties to insert malicious code. The new parser eliminates the need to use the eval() function, Crockford said.

Tim Bray, a co-creator of the XML format and director of Web technologies at Sun Microsystems, noted that XML practitioners he has worked with see the value of JSON.

"XML has a bunch of features which make it possible to interchange documents (blog pieces, news releases, medical records), and these can be superfluous for interchanging pure data," he noted by e-mail. "JSON works really well for interchanging that kind of stuff and, like XML, is nicely vendor-independent."

Bray doubts the ECMA blessing will have much impact on further JSON adoption though, since it is already widely used and doesn't suffer from the interoperability problems that standards usually address.

"Obviously, there's no harm in the ECMAScript [revision] recognizing the reality of JSON [but] JSON is already deeply implanted in Web IT culture."

ECMAScript is the vendor-neutral version of the JavaScript programming language, which was originally created by Netscape as a scripting language for Web browsers.

Follow Us

Join the newsletter!


Sign up to gain exclusive access to email subscriptions, event invitations, competitions, giveaways, and much more.

Membership is free, and your security and privacy remain protected. View our privacy policy before signing up.

Error: Please check your email address.

Tags javascriptXMLdata integrationJSON

Show Comments