Web サービス用に次の配列があります: {"update":true,"msg":"Logged in Bro","role":"admin"}
ここで、Android でこれを使用して、ログインを超えてアプリケーションを回避する必要があります。したがって、ここで必要なのは、このデータを名前と値のペアまたは個々の変数にフォーマットして、それらを使用できるようにする方法です。
私は現在これを使用していますが、アプリケーションを強制的に閉じます:
try {
JSONObject jsonRootObject = new JSONObject(result);
//Get the instance of JSONArray that contains JSONObjects
JSONArray jsonArray = jsonRootObject.optJSONArray("");
//Iterate the jsonArray and print the info of JSONObjects
for(int i=0; i < jsonArray.length(); i++){
JSONObject jsonObject = jsonArray.getJSONObject(i);
update = jsonObject.optString(jsonObject.optString("update").toString());
message = jsonObject.optString("msg").toString();
role = jsonObject.optString(jsonObject.optString("role").toString());
}
} catch (JSONException e) {e.printStackTrace();}