Fix the code to be defensive against invalid requests in `predict_from_json`.
