Throw exceptions for json() with no content.

This is a follow-up to #1665. This is a breaking API change, but can probably be put in a minor release (e.g. 2.1).