import org.json.JSONObject;
public class Login {
private String Username = "username";
private String Password = "password";
private String jsonString;
public String requestForLogin()
{
JSONObject jsonData = new JSONObject();
JSONObject jsonobject= new JSONObject();
try{
jsonobject.put("method", "login");
jsonobject.put("username", Username);
jsonobject.put("password",Password);
jsonobject.put("session_id","");
jsonobject.put("dev_type", "android");
jsonData.put("data", jsonobject);
jsonString=jsonData.toString();
}catch(Exception e)
{
e.printStackTrace();
}
return jsonString;
}
}
The json String is like:
{"data":{
"method": login" , "username":"username" , "password":"password" , "session_id":"" , "dev_type":"android"
}
}