Additional JSON Decode Messages

This gives additional messages in the situation where a JSON encode fails, hopefully aiding debugging.

Note: test cases incomplete for all the possible json_decode problems.