7.7.0.3

JSON: Simplicity and Complexity

At first glance, JSON is a simple notation for writing down information in terms of Booleans, Strings, Numbers, arrays of JSON expressions, and objects of JSON expressions. This transformation is known as parsing, which we will discuss in 2 — Parsing But, as it turns out, turning JSON information into internal data is a minefield. As it turns out, no two JSON parsers seem to accept the same JSON inputs.

You should keep this fact in mind for your upcoming co-op and future employment.

Since this course is not a software development course, we will always use a small subset of JSON on which all parsers should agree so that we don’t end up testing JSON-specific properties of the various languages in use. Thus, in this course
  • A JSON String is a non-empty sequence of at most 10 lowercase letters a through z plus the keyboard characters: !, @, $, %, ^, &, *, _, -, +, :, /, =

  • A JSON Integer is a non-empty sequence of digits (0 through 9), possibly preceded by a minus sign, in the range [-28, +28].

  • A JSON Float consists of a non-empty sequence of digits (0 through 9) combined via dot ., possibly preceded by a minus sign, according to the IEEE floating-point numbers standard. (A more precise definition will be supplied if needed.)

Any violation of these basic constraints in JSON test files means your homework grade goes down.

Furthermore, to keep things reasonably simple, our JSON reader process will limit the time it takes to read a JSON value from the file system. While an extremely large String that stress-tests a software system is appropriate for a course that focuses on software development, it is pointless for a course on the principles of programming languages.