Added toJson function to ErrorMessage, to facilitate communications with browser when doing ajax form submissions.