No data interchange format is perfect. ASN.1 (Abstract Syntax Notation One) is probably the closest (it's by far the most flexible and comprehensive), but since no one's really heard of it, it may as well be Esperanto. Although XML has become the de-facto standard, JSON (JavaScript Object Notation) has been gaining favor – especially for simple operations on the web.

For example, a JSON response to an authorization check might look something like this.

{
  "redirect_to": "http://initrode-global.com/auth/login.do?cmd=auth-success",
  "success": "true"
}

Just use JavaScript's built-in eval() method on the string of data, and you'll get an easy-to-use object graph. Even though it's JavaScript, there are encoding/decoding libraries in virtually every language. Even JavaScript, in case you don't want to eval() an arbitrary string.

But for whatever reason, Kazet's colleague opted not to employ any of these methods for dealing with JSON-encoded data in JavaScript, instead favoring regular expressions:

var redir = (data.match(new RegExp('\\{"redirect_to": "((http|https):/{2}.+auth/login.do\\?cmd=.+)'))||{})[1];

And of course, this usage was only discovered when a single space was added between the first { and the ".

[Advertisement] BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!