Add support for error response in JSON format. Closes #108, #109

Since #60 is probably too big, I propose to support at least JSON responses with this PR. Also, I do not agree how #92, #108 and #109 are trying to address the issue.

Closes #108, #109.

@toastdriven I think #92 should be fixed properly via #60 or something similar for new XML responses.
Sure, I can change it. I was trying to handle the case when the response could contain malformed JSON, but it is probably unlikely to happen.