Added handling of JSON errors for postprocessing

The odd UTF8 error or otherwise can cause nothing to output and you have no idea what the error could be. This outputs an error message if the framework failed to encode the json response successfully.

A fallback is also provided for pre-PHP5.5.0 support, as json_last_error_msg() is only in >=5.5