java.lang.ClassCastException: java.util.HashMap cannot be cast to com.parse.ParseObject
<p>This is my code to request the sendCode which is to be received by sms. When the number is enter and submitted it crashes and I still do receive the code by sms.    </p>

<pre><code>ParseCloud.callFunctionInBackground("sendCode", params, new FunctionCallback&lt;JSONObject&gt;() {
                    public void done(JSONObject response, ParseException e) {
                        progressBar.setVisibility(View.GONE);
                        if (e == null) {
                            Log.d("Cloud Response", "There were no exceptions! " + response.toString());
                            codeUI();
                        } else {
                            Log.d("Cloud Response", "Exception: " + response.toString() + e);
                            Toast.makeText(getApplicationContext(),
                                    "Something went wrong.  Please try again." + e,
                                    Toast.LENGTH_LONG).show();
                            phoneNumberUI();
                        }
                    }
                });
</code></pre>

<p>This is my JSON file on the Parse Cloud</p>

<pre><code>if (!phoneNumber || (phoneNumber.length != 10 &amp;&amp; phoneNumber.length != 11)) return res.error('Invalid Parameters');
    Parse.Cloud.useMasterKey();
    var query = new Parse.Query(Parse.User);
    query.equalTo('username', phoneNumber + "");
    query.first().then(function(result) {
        var min = 1000; var max = 9999;
        var num = Math.floor(Math.random() * (max - min + 1)) + min;

        if (result) {
            result.setPassword(secretPasswordToken + num);
            result.set("language", language);
            result.save().then(function() {
                return sendCodeSms(phoneNumber, num, language);
            }).then(function() {
                res.success({});
            }, function(err) {
                res.error(err);
            });
</code></pre>