Q:

Unable to frame jsonarray

Im trying to create a json array like the following
[
 "Login",
 {
  "login_type": "Android",
  "username": "gurusamy@mindssoft.com",
  "password": "123",
  "short_name": null,
  "ip": "122.164.164.35"
 }
]

Following is my code,
public JSONArray frameLoginJson() {
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("login_type", "Android");
            jsonObject.put("username", email);
            jsonObject.put("password", password);
            jsonObject.put("short_name", null);
            jsonObject.put("ip", "124.5.67.3");

        } catch (JSONException e) {
            e.printStackTrace();
        }

        JSONArray jsonArray = new JSONArray();
        jsonArray.put(jsonObject);

        //Toast.makeText((), "" + jsonObject, Toast.LENGTH_SHORT).show();
        return jsonArray;
    }

The problem is that it is not framing the json exactly. Where am i missing the point?

A:

JSONArray jsonArray=new JSONArray();
jsonArray.put("Login");
        JSONObject jsonObject=new JSONObject();
        try {
            jsonObject.put("login_type", "Android");
            jsonObject.put("username", email);
            jsonObject.put("password", password);
            jsonObject.put("short_name", null);
            jsonObject.put("ip", "124.5.67.3");
        } catch (JSONException e) {
            e.printStackTrace();
        }

jsonArray.put(jsonObject);

