senchalabs/connect — pull request #487 by jmar777 (2012-02-27 20:10:25+00:00)
Title: RFC 4627 (application/json) compliance improvement

Currently the json middleware allows any request bodies that don't throw on `JSON.parse()`. This is a divergence from the RFC specifications for *application/json*, as `JSON.parse()` will successfully parse all JSON values. This is not equivalent with valid *application/json* bodies as defined by the RFC, however.

According to the specifications, `application/json` (referred to as "JSON text") must be a valid JSON `Object` or `Array`. This means that not all values that pass the `JSON.parse()` test (e.g., `'"foo bar"'`) are necessarily valid *application/json*. This pull request simply ensures that values that pass the `JSON.parse()` test also pass a quick test ensuring `Object` or `Array` values.

The pull request also includes a test case demonstrating the problem.