Return json when json is requested

422 (unprocessable_entity) seems like a more appropriate HTTP response code for unparsable json. Also, for a json api, it seems preferable if the response is json instead of an HTML error page.
BTW, This is should be handled by public_exception already https://github.com/danrabinowitz/rails/blob/return-json-when-json-is-requested/actionpack/lib/action_dispatch/middleware/public_exceptions.rb#L33