它只显示一个值,如ram@gmail.com或ram
JSONObject json = new JSONObject(result);
code = (json.getInt("success"));
if (code ==1) {
JSONArray user=json.getJSONArray("user");
JSONObject product = user.getJSONObject(0);
email1.setText(product.optString("email"));
name1.setText(product.optString("name"));
//nid.setText(product.getString("name"));
Log.v("email",email1.toString());
Toast.makeText(context,"Data successfully inserted",Toast.LENGTH_SHORT).show();
Log.i("msg", "Data Successfully Inserted");
//Data Successfully Inserted
} else {
Toast.makeText(context,"Data are not successfully inserted",Toast.LENGTH_SHORT).show();
//Data Not Inserted
}
答案 0 :(得分:0)
这是你的意思吗?
for (int i=0; i < user.length(); i++)
{
try {
JSONObject product = user.getJSONObject(i);
// product.optString("email")
// product.optString("name")
} catch (JSONException e) {
}
}