I want to program a nested JSON Object for my Android device, but how? I have only basic experience with Json, so I would appreciate if someone could help me with the following code:
{
"command": "login",
"uid": "123123123",
"params":
{
"username": "sup",
"password": "bros"
}
}
Edit:
The following code does solve the problem:
loginInformation = new ArrayList<NameValuePair>();
JSONObject parentData = new JSONObject();
JSONObject childData = new JSONObject();
try {
parentData.put("command", "login");
parentData.put("uid", UID.getDeviceId());
childData.put("username", username.getText().toString());
childData.put("password", password.getText().toString());
parentData.put("params", childData);
} catch (JSONException e) {
e.printStackTrace();
}
loginInformation.add(new BasicNameValuePair("content", parentData.toString()));