Peps Peps - 28 days ago 4
Android Question

JSON Parsing in Android

I am having problem parsing JSON in my

I am creating an android app that will request for the user to input the username and password and after clicking the button it will now send a POST request and the request will response with a JSON data.

Here is my request in android studio:

//StudentInfo or Login"<url here>", params, new AsyncHttpResponseHandler() {

public void onSuccess(String response) {
StudentModel sm = new StudentModel(obj);
flag = true;
Toast.makeText(getApplicationContext(), "Redirecting...", Toast.LENGTH_LONG).show();
}catch(Exception e){
Toast.makeText(getApplicationContext(), "Error Occured [Server's JSON response might be invalid]!", Toast.LENGTH_LONG).show();

And here is my StudentModel.class

public void retrievalData(){
//some code to parse the JSON


Well, I am a beginner in json parsing and here is the JSON Response.

"info": {
"add": "<data>",
"firstName": "<data>",
"lastName": "<data>",
"middleName": "<data>",


Well, what you can do in retrievalData() is:

String add = <JSONobjectVariableName>.getJSONObject("info").getString("add");
String firstName = <JSONobjectVariableName>.getJSONObject("info").getString("firstName");

and so on.