Code example for JSONObject: Parsing JSON documents

Methods: getJSONObject, has

0
        } 
 
        @Override 
        protected void onPostExecute(String jsonResult) {
            try { 
                JSONObject response = new JSONObject(jsonResult);
                Log.d("JSONRESPONSE", jsonResult);
                // If the result gives us a uuid, we know that the account has been created 
                // successfully. 
                if (response.has("uuid")) {
                    onAccountCreateSuccess(); 
                } 
 
                // We should never get any form errors because we check for all of those conditions 
                // locally. This is just here as a safeguard and should temporarily handle any 
                // changes to the requirements of these fields. 
                else if (response.has("form_errors")) {
                    JSONObject errors = response.getJSONObject("form_errors");
                    if (errors.has("mail")) {
                        emailError(2); 
                    } 
                    if (errors.has("pass")) {
                        passwordError(3); 
                    } 
                    if (errors.has("field_firstname")) {
                        firstNameError(); 
                    } 
                    if (errors.has("field_lastname")) {
                        lastNameError(); 
                    } 
                    if (errors.has("field_birth_date")) {
                        birthDateError(); 
                    } 
 
                    // If there was a form error found by the server, we will need a new captcha. 
                    // This should never occur though because we check for all of the registration