Final Result of Webservice
[{
"Type": "Data",
"d": {
"UserID": "30Bq33f685k=",
"Name": "testing13",
"TuitionID": "30Bq33f685k=",
"ContactNo": "",
"UserType": "UserAdmin"
}
}, {
"Type": "Message",
"d": ""
}]
In my case one json array and two object
Step-1
Store result to resultstring
resultString = (SoapPrimitive) envelope.getResponse();
Step-2
Store result in jsonstring for create json array
String jsonStr = String.valueOf(resultString);
Log.e(TAG, "Response from result" + resultString);
if (jsonStr != null) {
Step-3
Create json array and parameter
JSONArray jsonArray = new JSONArray(jsonStr);
Log.e(TAG, resultString.toString());
for (int i = 0; i < jsonArray.length(); i++) {
// Toast.makeText(Loginscreen_activity.this, "demo.....", Toast.LENGTH_SHORT).show();
JSONObject c = jsonArray.optJSONObject(0);
if (i == 0 && c.optString("d").equalsIgnoreCase("Invalid login")) {
runOnUiThread(new Runnable() {
@Override public void run() {
Toast.makeText(Loginscreen_activity.this, "Error", Toast.LENGTH_SHORT).show();
}
});
} else {
final JSONObject data = c.optJSONObject("d");
model model = new model();
model.setUserid(data.optString("UserID"));
model.setName(data.optString("Name"));
model.setTuitionid(data.optString("TuitionID"));
model.setContactno(data.optString("ContactNo"));
model.setUsertype(data.optString("UserType"));
list.add(model);
Log.d("ARRAY>> ", "" + list.size());
}
}
Log.d("ArraySize", String.valueOf(jsonArray));
}
0 comments:
Post a Comment