Handle both JSONDecodeError and ValueError due to differences in json vs. simplejson

This merges in #1633 from @kurin, but makes the following changes:

 1. Catches both `JSONDecodeError` and `ValueError`
 2. Adds a new test to verify behavior if either exception is thrown