Potential ambiguity is a mess

The idea behind data format standards is to ensure that disparate tools can communicate using a common “language.”  When the standard includes potential ambiguity, things get messy.

A case in point is JSON (Javascript Object Notation).  The standard for escaping characters in strings looks like this:

In English, that says that the only characters that must be escaped are quote (“), backslash¹ (\), and control characters.  An escaped character starts with backslash and the following character(s) must be one of those identified.  That’s all good except for one item:  the “solidus” (/).  That character can be escaped, but it does not have to be.  So in a string, “/” and “\/” mean the same thing.

Why?  The potential ambiguity here is the exception to the rule.  Somebody implementing a JSON processor might easily interpret that to mean that the slash (I’m sorry, “solidus”) must be escaped.

¹”solidus”? Learn something new every day. It’s too bad that they didn’t come up with a unique name for “\”.  “Reverse solidus” is harder to say than “backslash.”

Comments are closed.



A sample text widget

