I'm unsure how to correctly send and receive requests from both the Android side and from the server side. 

Lets say for example, during registration, I want to check if a user exists by checking their email address against the DB.

My current understanding of how to implement this would be as follows: 

Android request code: 

```
    @Override
    public void onClick(View v) { //Assume this request is performed on a button click

    JSONObject registrationRequestDetails = new JSONObject(); //Creating a JSON object to be sent to the server
    try {
      registrationRequestDetails.put("email", emailBox.getText().toString());
    } catch (JSONException e) {
      Log.e("Couldn't create JSON: ", e.toString());
    }

    JsonObjectRequest loginRequest = new JsonObjectRequest(Request.Method.POST,
        URL,
        loginRequestDetails,
        new Response.Listener<JSONObject>() {
          @Override
          public void onResponse(JSONObject response) {
            try {
              if (response.get("result").equals("registered")) {
                //Assuming a JSON object is returned here, something akin to "result":"registered" if the email does exist - do something
              } else {
                //Email doesn't exist
              }
            } catch (JSONException e) {
              e.printStackTrace();
            }
          }
        }, new Response.ErrorListener() {
      @Override
      public void onErrorResponse(VolleyError error) {
        Log.e("Something: ", error.toString());
      }
    });
    loginRequestQueue.add(loginRequest);
  }
});

```

Spring Boot server code:

UserController.java

```
@RequestMapping(value = "/register", method = RequestMethod.POST, consumes = "application/json", produces = "application/json") //Want to accept JSON & return JSON
//I return a Map below because I do not understand if this is the correct way to return JSON format - what is the correct way??
public Map<String, String> registerNewUser(@RequestBody final Map<String, String> details) {
    return registrationService.checkIfUserAlreadyExists(details);
}

```

RegistrationService.java

```
//Assume repo is injected that checks if email exists

public Map<String, String> checkIfUserAlreadyExists(Map<String, String> user) { //Should I be returning response status instead of JSON?
    Map<String, String> resultMap = new HashMap<>();
    if (usersRepository.existsByEmailAddress(user.get("email_address"))) {
        resultMap.put("result", "error");
        return resultMap;
    } else {
        //Save email if not registered
        resultMap.put("result", "registered");
        return resultMap;
    }
}

```

Currently, this works. But i'm unsure if it is the correct way to go about this. Can anyone explain what is the correct way to accept and return JSON data? 

Also, during the registration process for example, what should actually be returned upon successful (or not) registration from the server?