Error when response is not json encoded

Use `json_last_error()` to detect parsing errors when parsing error responses. Fixes #78.