add .json method to error object