Added error checking for Curl & JSON

Was missing the checks and scratched my head with:
 - Malformed HTTP responses/Curl errors: e.g. Tranfer-Encoding truncated was encoded wrong
 - Malformed JSON encode/decodes