Search code examples
jsonandroid-studioorg.json

How do I add JSON get method in my android app


I am trying to develop a simple android app where a user can enter a username and password and then when they click login, it compares the information with that in the database. If the information is correct, then a new activity is opened showing success message. I would like to use JSON get method. I already have an API key for this but am an absolute beginner so any help on how to go about this will be highly appreciated


Solution

  • I am assuming you want to take Username and Password as input from user and then want to call an API for authentication. Suppose your input json object looks something like this

    {
    "Username":"myName",
    "Password":"qwerty"
    }
    

    then you can get the required information like

    jsonObject.get("Username");
    

    this will return you the user entered name and same goes for password as well then you can call the authentication API using this information.