Return JSON errors when parameter validation fails.

In common with other errors, parameter validation errors should be in JSON format (currently they are in plain text).