當前位置: 首頁>>代碼示例>>Java>>正文


Java JSONObject.accumulate方法代碼示例

本文整理匯總了Java中org.json.JSONObject.accumulate方法的典型用法代碼示例。如果您正苦於以下問題:Java JSONObject.accumulate方法的具體用法?Java JSONObject.accumulate怎麽用?Java JSONObject.accumulate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.json.JSONObject的用法示例。


在下文中一共展示了JSONObject.accumulate方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: convertUser

import org.json.JSONObject; //導入方法依賴的package包/類
public static JSONObject convertUser(){
    Realm realm= Realm.getDefaultInstance();
    User user=realm.where(User.class).findFirst();
    try {
        JSONObject jUser=new JSONObject();
        jUser.accumulate("id",user.getId());
        jUser.accumulate("token",user.getToken());
        jUser.accumulate("lessThan",user.getLessThan());
        jUser.accumulate("greaterThan",user.getGreaterThan());
        jUser.accumulate("lastseen",user.getLastSeen());
        jUser.accumulate("registered",user.getDateRegistered());
        jUser.accumulate("userJsonObj",user.getUserJsonObj());
        return jUser;
    }catch (Exception e){
        e.printStackTrace();
    }finally {
        realm.close();
    }
    return new JSONObject();
}
 
開發者ID:nyangate,項目名稱:Crypto-Assistant,代碼行數:21,代碼來源:CryptoAssistant.java

示例2: handleGetProgress

import org.json.JSONObject; //導入方法依賴的package包/類
String handleGetProgress(Request req, Response res) {
  String url = req.queryMap( "url" ).value();
  Optional<ScrapeJob> optJob = MAN.getJob(url);
  if ( optJob.isPresent() ) {
    ScrapeJob job = optJob.get();
    JSONObject response = new JSONObject();
    res.type("application/json");
    response.accumulate( "finished", job.isJobDone() );
    response.accumulate( "done", job.getNumDone() );
    response.accumulate( "total", job.getTotal() );
    response.accumulate( "layer", job.getName() );
    response.accumulate( "failed", job.isFailed() );
    if(job.isFailed()) {
      response.accumulate( "errorMessage", job.getFailMessage() );
    }
    return response.toString();
  } else {
    return NO_JOB_FOUND_MESSAGE;
  }
}
 
開發者ID:mchaynes,項目名稱:northpine,代碼行數:21,代碼來源:ServerHandler.java

示例3: addFilter

import org.json.JSONObject; //導入方法依賴的package包/類
private boolean addFilter(FilterRule filterRule, boolean overwrite) {
	try {
		JSONObject data = FilterRule.loadSavedFilterRules(this, overwrite);
		if (getIntent().getBooleanExtra("modify", false))
			data.getJSONArray("rules").put(getIntent().getIntExtra("index", 0), filterRule.toJSONObject());
		else
			data.accumulate("rules", filterRule.toJSONObject());
		FilterRule.saveRules(this, data);
		return false;
	} catch (Exception e) {
		e.printStackTrace();
		if (overwrite)
			new AlertDialog.Builder(this)
					.setTitle(R.string.error_write_file)
					.setMessage(getString(R.string.error_saving_filter_rule, e.getMessage()))
					.setNeutralButton(getString(R.string.ok), new DialogInterface.OnClickListener() {
						@Override
						public void onClick(DialogInterface dialog, int which) {
							dialog.dismiss();
						}
					})
					.show();
		return true;
	}
}
 
開發者ID:SapuSeven,項目名稱:NotiCap,代碼行數:26,代碼來源:AddFilterRuleActivity.java

示例4: addIdentity

import org.json.JSONObject; //導入方法依賴的package包/類
private boolean addIdentity(SSHIdentity identity, boolean overwrite) {
	try {
		JSONObject data = SSHIdentity.loadSavedIdentities(this, overwrite);
		if (getIntent().getBooleanExtra("modify", false))
			data.getJSONArray("identities").put(getIntent().getIntExtra("index", 0), identity.toJSONObject());
		else
			data.accumulate("identities", identity.toJSONObject());
		SSHIdentity.saveIdentities(this, data);
		return false;
	} catch (Exception e) {
		e.printStackTrace();
		if (overwrite)
			new AlertDialog.Builder(this)
					.setTitle(R.string.error_write_file)
					.setMessage(getString(R.string.error_saving_identity, e.getMessage()))
					.setNeutralButton(getString(R.string.ok), new DialogInterface.OnClickListener() {
						@Override
						public void onClick(DialogInterface dialog, int which) {
							dialog.dismiss();
						}
					})
					.show();
		return true;
	}
}
 
開發者ID:SapuSeven,項目名稱:NotiCap,代碼行數:26,代碼來源:AddSSHIdentityActivity.java

示例5: Register

import org.json.JSONObject; //導入方法依賴的package包/類
public boolean Register(String nick, String email, String password, Intent intent) throws JSONException, IOException {
        JSONObject jsonObject = new JSONObject();
//        jsonObject.accumulate("client_id",context.getString(R.string.clientid));
//        jsonObject.accumulate("client_secret", context.getString(R.string.clientsecret));
//        jsonObject.accumulate("grant_type", "password");
        jsonObject.accumulate("email", email);
        jsonObject.accumulate("password", password);
        jsonObject.accumulate("first_name",nick);
        String json = jsonObject.toString();
        Log.d("mesaj"," "+json);
        con.getOutputStream().write(json.getBytes());
        if(con.getResponseCode()<300){
            JSONObject finalResuslt = response(con);
            Log.d("response","register  "+finalResuslt);
            preferencesShared.putString("accesstoken",finalResuslt.getString("access_token"));
            preferencesShared.putString("refreshToken",finalResuslt.getString("refresh_token"));
            preferencesShared.putLong("timeout", (System.currentTimeMillis() +((finalResuslt.getLong("expires_in") - 100) * 1000)));
            preferencesShared.putString("username", finalResuslt.getString("username"));
            preferencesShared.commit();
            con.disconnect();
            context.startActivity(intent);
            context.finish();
            return true;
        }
        else{
            InputStream stream = con.getErrorStream();
            BufferedReader br = new BufferedReader(new InputStreamReader(stream));
            String line;
            StringBuilder str = new StringBuilder();
            while((line = br.readLine())!=null){
                str.append(line).append("\n");
            }
            Log.d("error", " " + con.getResponseCode() + " mes " + con.getResponseMessage()+"  fc  " + str.toString());
            Toast.makeText(context, str.toString(), Toast.LENGTH_LONG).show();
        }
        con.disconnect();
        return false;
    }
 
開發者ID:TudorRosca,項目名稱:enklave,代碼行數:39,代碼來源:Register.java

示例6: getJsonRequest

import org.json.JSONObject; //導入方法依賴的package包/類
private static JSONObject getJsonRequest(Object params, Session appSession) throws JSONException {
        if (params == null) {
            return new JSONObject();
        }

        HashMap<String, Object> requestParams;
        if (params instanceof HashMap) {
            requestParams = (HashMap<String, Object>) params;
        } else {
            return new JSONObject();
        }

        // add parameter node
        final Iterator<String> keySet = requestParams.keySet().iterator();
        JSONObject jsonParams = new JSONObject();

        try {
            while (keySet.hasNext()) {
                final String key = keySet.next();
                Object val = requestParams.get(key);
                if (val == null) {
                    val = "";
                }
                if (val instanceof String || val instanceof Number) {
                    jsonParams.accumulate(key, val);
                } else if (val instanceof List<?>) {
                    jsonParams.accumulate(key, getJSONArray((List<?>) val).toString());
                } else {
                    jsonParams.accumulate(key, getJSONObject(val).toString());
                }
            }
            LogUtils.i("請求數據包參數:" + jsonParams.toString());
//            return new StringEntity(DesUtils.encrypt(jsonParams.toString()), HTTP.UTF_8);
            return jsonParams;

        } catch (Exception e) {
            e.printStackTrace();
            return new JSONObject();
        }
    }
 
開發者ID:SavorGit,項目名稱:Hotspot-master-devp,代碼行數:41,代碼來源:ApiRequestFactory.java

示例7: connectLogin

import org.json.JSONObject; //導入方法依賴的package包/類
public boolean connectLogin(String user,String password) throws JSONException, IOException {
    JSONObject jsonObject = new JSONObject();
    jsonObject.accumulate("client_id",context.getString(R.string.clientid));
    jsonObject.accumulate("client_secret", context.getString(R.string.clientsecret));
    jsonObject.accumulate("grant_type", "password");
    jsonObject.accumulate("username", user);
    jsonObject.accumulate("password", password);
    String json = jsonObject.toString();
    con.getOutputStream().write(json.getBytes());
    Log.d("intra"," "+con.getResponseMessage());
    if(con.getResponseCode()<300){
        JSONObject finalResuslt = response(con);
        preferencesShared.putString("accesstoken",finalResuslt.getString("access_token"));
        preferencesShared.putString("refreshToken",finalResuslt.getString("refresh_token"));
        preferencesShared.putLong("timeout", (System.currentTimeMillis() +((finalResuslt.getLong("expires_in") - 1000) * 1000)));
        preferencesShared.putString("username", user);
        preferencesShared.commit();
        con.disconnect();
        return true;
    }
    else{
        Log.d("error", " " + con.getResponseCode() + " mes " + con.getResponseMessage() + con.getContentEncoding());
        Toast.makeText(context, "User Name Or Password is Wrong!", Toast.LENGTH_LONG).show();
    }
    Log.d("raspuns "+con.getResponseCode(),"sagg");
    con.disconnect();
    return false;
}
 
開發者ID:TudorRosca,項目名稱:enklave,代碼行數:29,代碼來源:LoginRefresh.java

示例8: refresh

import org.json.JSONObject; //導入方法依賴的package包/類
public boolean refresh() throws JSONException, IOException {
    long timeout = preferencesShared.getLong("timeout",0);
    if(timeout > System.currentTimeMillis()){
        return true;
    }else {
        JSONObject jsonObject = new JSONObject();
        jsonObject.accumulate("client_id", context.getString(R.string.clientid));
        jsonObject.accumulate("client_secret", context.getString(R.string.clientsecret));
        jsonObject.accumulate("grant_type", "refresh_token");
        jsonObject.accumulate("username", preferencesShared.getString("username", ""));
        jsonObject.accumulate("refresh_token", preferencesShared.getString("refreshToken", ""));
        String json = jsonObject.toString();
        con.getOutputStream().write(json.getBytes());
        Log.d("intra"," "+con.getResponseMessage());
        if (con.getResponseCode() < 300) {
            JSONObject finalResuslt = response(con);
            preferencesShared.putString("accesstoken", finalResuslt.getString("access_token"));
            preferencesShared.putString("refreshToken", finalResuslt.getString("refresh_token"));
            preferencesShared.putLong("timeout", (System.currentTimeMillis() + ((finalResuslt.getLong("expires_in") - 100) * 1000)));
            preferencesShared.commit();
            con.disconnect();
            return true;
        } else {
            con.disconnect();
            return false;
        }
    }
}
 
開發者ID:TudorRosca,項目名稱:enklave,代碼行數:29,代碼來源:LoginRefresh.java

示例9: sendMessage

import org.json.JSONObject; //導入方法依賴的package包/類
public void sendMessage(String message){
    final Preferences pref = Gdx.app.getPreferences("informationLog");
    String acces = pref.getString("accesstoken");
    JSONObject json = new JSONObject();
    json.accumulate("txt",message);
    HttpRequestBuilder builder = new HttpRequestBuilder();
    Net.HttpRequest request = builder.newRequest().method(Net.HttpMethods.POST).url(url + join).build();
    request.setHeader("Authorization", "Bearer " + acces);
    request.setHeader("Content-type", "application/json");
    request.setContent(json.toString());
    Gdx.net.sendHttpRequest(request, new Net.HttpResponseListener() {
        @Override
        public void handleHttpResponse(Net.HttpResponse httpResponse) {
            //Gdx.app.log("response :"+httpResponse.getStatus().getStatusCode(),"message "+httpResponse.getResultAsString());
        }

        @Override
        public void failed(Throwable t) {
            //Gdx.app.log("response :","failed "+t);
        }

        @Override
        public void cancelled() {
            //Gdx.app.log("response :","cancel ");
        }
    });
}
 
開發者ID:TudorRosca,項目名稱:enklave,代碼行數:28,代碼來源:SendFaction.java

示例10: sendMessage

import org.json.JSONObject; //導入方法依賴的package包/類
public void sendMessage(String message){
        final Preferences pref = Gdx.app.getPreferences("informationLog");
        String acces = pref.getString("accesstoken");
        JSONObject json = new JSONObject();
        json.accumulate("txt",message);
        HttpRequestBuilder builder = new HttpRequestBuilder();
        Net.HttpRequest request = builder.newRequest().method(Net.HttpMethods.POST).url(url + join).build();
        request.setHeader("Authorization", "Bearer " + acces);
        request.setHeader("Content-type", "application/json");
        request.setContent(json.toString());
        Gdx.net.sendHttpRequest(request, new Net.HttpResponseListener() {
            @Override
            public void handleHttpResponse(Net.HttpResponse httpResponse) {
//                Gdx.app.log("response :"+httpResponse.getStatus().getStatusCode(),"message "+httpResponse.getResultAsString());
            }

            @Override
            public void failed(Throwable t) {
                //Gdx.app.log("response :","failed "+t);
            }

            @Override
            public void cancelled() {
                //Gdx.app.log("response :","cancel ");
            }
        });
    }
 
開發者ID:TudorRosca,項目名稱:enklave,代碼行數:28,代碼來源:SendLocation.java

示例11: makeRequest

import org.json.JSONObject; //導入方法依賴的package包/類
public void makeRequest(int id){
    final Preferences pref = Gdx.app.getPreferences("informationLog");
    String acces = pref.getString("accesstoken");
    JSONObject json = new JSONObject();
    json.accumulate("faction_id",id);
    HttpRequestBuilder builder = new HttpRequestBuilder();
    Net.HttpRequest request = builder.newRequest().method(Net.HttpMethods.POST).url(url + join).build();
    request.setHeader("Authorization", "Bearer " + acces);
    request.setHeader("Content-type", "application/json");
    request.setContent(json.toString());
    Gdx.net.sendHttpRequest(request, new Net.HttpResponseListener() {
        @Override
        public void handleHttpResponse(Net.HttpResponse httpResponse) {
            //Gdx.app.log("response :","message "+httpResponse.getResultAsString());
        }

        @Override
        public void failed(Throwable t) {
            //Gdx.app.log("response :","failed ");
        }

        @Override
        public void cancelled() {
            //Gdx.app.log("response :","cancel ");
        }
    });
}
 
開發者ID:TudorRosca,項目名稱:enklave,代碼行數:28,代碼來源:JoinFaction.java

示例12: makeRequest

import org.json.JSONObject; //導入方法依賴的package包/類
public void makeRequest(int id, final ScreenCombat screenCombat){
    final Preferences pref = Gdx.app.getPreferences("informationLog");
    final String acces = pref.getString("accesstoken");
    JSONObject parameters = new JSONObject();
    parameters.accumulate("enklave_combat_id",id);
    HttpRequestBuilder builder = new HttpRequestBuilder();
    Net.HttpRequest request = builder.newRequest().method(Net.HttpMethods.POST).url(url + prof).build();
    request.setHeader("Authorization", "Bearer " + acces);
    request.setHeader("Content-type", "application/json");
    request.setContent(parameters.toString());
    Gdx.net.sendHttpRequest(request, new Net.HttpResponseListener() {
        @Override
        public void handleHttpResponse(Net.HttpResponse httpResponse) {
            screenCombat.showCover();
            Gdx.app.log("raspuns hit Enklave cod :"+httpResponse.getStatus().getStatusCode()," message : "+httpResponse.getResultAsString());
        }

        @Override
        public void failed(Throwable t) {

        }

        @Override
        public void cancelled() {

        }
    });
}
 
開發者ID:TudorRosca,項目名稱:enklave,代碼行數:29,代碼來源:HitEnklave.java

示例13: makeRequest

import org.json.JSONObject; //導入方法依賴的package包/類
public void makeRequest(int id, final ScreenCombat screenCombat){
    final Preferences pref = Gdx.app.getPreferences("informationLog");
    final String acces = pref.getString("accesstoken");
    JSONObject jsonObject = new JSONObject();
    jsonObject.accumulate("enklave_id", id);
    HttpRequestBuilder builder = new HttpRequestBuilder();
    Net.HttpRequest request = builder.newRequest().method(Net.HttpMethods.POST).url(url + prof).build();
    request.setHeader("Authorization", "Bearer " + acces);
    request.setHeader("Content-type", "application/json");
    request.setContent(jsonObject.toString());
    Gdx.net.sendHttpRequest(request, new Net.HttpResponseListener() {
        @Override
        public void handleHttpResponse(Net.HttpResponse httpResponse) {
            String res = httpResponse.getResultAsString();
            Gdx.app.log("raspuns start code "+httpResponse.getStatus().getStatusCode(),"rasp mess: "+res);
            if(httpResponse.getStatus().getStatusCode()<300){
                JSONObject j = new JSONObject(res);
                informationProfile.getDateUserGame().setEnklaveCombatId(j.getInt("enklave_combatant_id"));
                InformationEnklave.getInstance().setCombatId(j.getInt("enklave_combat_id"));
                informationProfile.getDateUserGame().setInCombat(true);
            }else{
                JSONObject json = new JSONObject(res);
                if(json.getString("detail").contentEquals("You already joined this combat once"))
                    InformationProfile.getInstance().getDateUserGame().setEnklaveCombatId(-1);
                informationProfile.getDateUserGame().setInCombat(true);
                screenCombat.dialogExit(json.getString("detail").substring(0,20)+"\n"+json.getString("detail").substring(21));
            }
        }

        @Override
        public void failed(Throwable t) {
            Gdx.app.log("error parse data : ","err: "+t);
        }

        @Override
        public void cancelled() {

        }
    });
}
 
開發者ID:TudorRosca,項目名稱:enklave,代碼行數:41,代碼來源:StartCombat.java

示例14: makeRequest

import org.json.JSONObject; //導入方法依賴的package包/類
public void makeRequest(int id){
    final Preferences pref = Gdx.app.getPreferences("informationLog");
    final String acces = pref.getString("accesstoken");
    JSONObject parameters = new JSONObject();
    parameters.accumulate("enklave_id",id);
    HttpRequestBuilder builder = new HttpRequestBuilder();
    Net.HttpRequest request = builder.newRequest().method(Net.HttpMethods.POST).url(url + prof).build();
    request.setHeader("Authorization", "Bearer " + acces);
    request.setHeader("Content-type", "application/json");
    request.setContent(parameters.toString());
    Gdx.net.sendHttpRequest(request, new Net.HttpResponseListener() {
        @Override
        public void handleHttpResponse(Net.HttpResponse httpResponse) {
            Gdx.app.log("raspuns unsubscribe cod :"," message : "+httpResponse.getResultAsString());
        }

        @Override
        public void failed(Throwable t) {

        }

        @Override
        public void cancelled() {

        }
    });
}
 
開發者ID:TudorRosca,項目名稱:enklave,代碼行數:28,代碼來源:UnsubscribeCombat.java

示例15: makeRequest

import org.json.JSONObject; //導入方法依賴的package包/類
public void makeRequest(int id, final ScreenCombat screenCombat){
    final Preferences pref = Gdx.app.getPreferences("informationLog");
    final String acces = pref.getString("accesstoken");
    JSONObject parameters = new JSONObject();
    parameters.accumulate("enklave_combatant_id",id);
    HttpRequestBuilder builder = new HttpRequestBuilder();
    Net.HttpRequest request = builder.newRequest().method(Net.HttpMethods.POST).url(url + prof).build();
    request.setHeader("Authorization", "Bearer " + acces);
    request.setHeader("Content-type", "application/json");
    request.setContent(parameters.toString());
    Gdx.net.sendHttpRequest(request, new Net.HttpResponseListener() {
        @Override
        public void handleHttpResponse(Net.HttpResponse httpResponse) {
            screenCombat.showCover();
            Gdx.app.log("raspuns hit user cod :"+httpResponse.getStatus().getStatusCode()," message : "+httpResponse.getResultAsString());
        }

        @Override
        public void failed(Throwable t) {

        }

        @Override
        public void cancelled() {

        }
    });
}
 
開發者ID:TudorRosca,項目名稱:enklave,代碼行數:29,代碼來源:HitUser.java


注:本文中的org.json.JSONObject.accumulate方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。