issue 203: test json_last_error() after json_encode() or json_decode()

From WCNY hack day. A couple notes:

* I gave the option of translation for the range of potential error messages. Probably overkill.
* Do you think it's worth being so specific with the error messages or would just a blanket "There was an error with json_encode()" suffice?
* Also probably overkill to test `defined()` for each PHP JSON constant instead of just a switch statement. 

Happy to revise as needed.

Fixes #203.
The status code here should be 500 rather than 400, as it's an internal error.