Add function to return JSON encoded errors.
Merge pull request #1 from khanov/Simple-JSON-Version

Add function to return JSON encoded errors.