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


Java JSONObject.putAll方法代碼示例

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


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

示例1: writeJson

import org.json.simple.JSONObject; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
private void writeJson(HttpServletResponse response, Map<String, Object> sessionParams) throws ServletException {
	try {
		JSONObject json = new JSONObject();
		json.putAll(sessionParams);
		response.setContentType("application/json");
		response.setHeader("Cache-Control", "no-cache");

		if (log.isTraceEnabled()) {
			log.trace("Responding with: " + json.toJSONString());
		}

		response.getWriter().write(json.toJSONString());
	} catch (IOException e) {
		throw new ServletException("Could not create json.", e);
	}
}
 
開發者ID:nortal,項目名稱:cas-modules,代碼行數:18,代碼來源:MobileIdController.java

示例2: createResponse

import org.json.simple.JSONObject; //導入方法依賴的package包/類
/**
 * boxインストールが実行されていないか、実行されたがキャッシュの有効期限が切れた場合のレスポンスを作成する.
 * @return レスポンス用JSONオブジェクト
 */
@SuppressWarnings("unchecked")
private JSONObject createResponse(JSONObject values) {
    JSONObject response = new JSONObject();
    response.putAll(values);
    response.remove("cell_id");
    response.remove("box_id");
    response.put("schema", this.getBox().getSchema());
    ProgressInfo.STATUS status = ProgressInfo.STATUS.valueOf((String) values.get("status"));
    if (status == ProgressInfo.STATUS.COMPLETED) {
        response.remove("progress");
        String startedAt = (String) response.remove("started_at");
        response.put("installed_at", startedAt);
    }
    response.put("status", status.value());
    return response;
}
 
開發者ID:personium,項目名稱:personium-core,代碼行數:21,代碼來源:BoxResource.java

示例3: getJSONObject

import org.json.simple.JSONObject; //導入方法依賴的package包/類
@Override
public JSONObject getJSONObject() {
    JSONObject json = new JSONObject();
    json.put("type", type.getType());
    json.put("subtype", type.getSubtype());
    json.put("timestamp", timestamp);
    json.put("deadline", deadline);
    json.put("senderPublicKey", Convert.toHexString(senderPublicKey));
    if (type.hasRecipient()) {
        json.put("recipient", Convert.toUnsignedLong(recipientId));
    }
    json.put("amountNQT", amountNQT);
    json.put("feeNQT", feeNQT);
    if (referencedTransactionFullHash != null) {
        json.put("referencedTransactionFullHash", referencedTransactionFullHash);
    }
    json.put("ecBlockHeight", ecBlockHeight);
    json.put("ecBlockId", Convert.toUnsignedLong(ecBlockId));
    json.put("signature", Convert.toHexString(signature));
    JSONObject attachmentJSON = new JSONObject();
    for (Appendix appendage : appendages) {
        attachmentJSON.putAll(appendage.getJSONObject());
    }
    //if (! attachmentJSON.isEmpty()) {
        json.put("attachment", attachmentJSON);
    //}
    json.put("version", version);
    return json;
}
 
開發者ID:muhatzg,項目名稱:burstcoin,代碼行數:30,代碼來源:TransactionImpl.java

示例4: unconfirmedTransaction

import org.json.simple.JSONObject; //導入方法依賴的package包/類
static JSONObject unconfirmedTransaction(Transaction transaction) {
    JSONObject json = new JSONObject();
    json.put("type", transaction.getType().getType());
    json.put("subtype", transaction.getType().getSubtype());
    json.put("timestamp", transaction.getTimestamp());
    json.put("deadline", transaction.getDeadline());
    json.put("senderPublicKey", Convert.toHexString(transaction.getSenderPublicKey()));
    if (transaction.getRecipientId() != 0) {
        putAccount(json, "recipient", transaction.getRecipientId());
    }
    json.put("amountNQT", String.valueOf(transaction.getAmountNQT()));
    json.put("feeNQT", String.valueOf(transaction.getFeeNQT()));
    if (transaction.getReferencedTransactionFullHash() != null) {
        json.put("referencedTransactionFullHash", transaction.getReferencedTransactionFullHash());
    }
    byte[] signature = Convert.emptyToNull(transaction.getSignature());
    if (signature != null) {
        json.put("signature", Convert.toHexString(signature));
        json.put("signatureHash", Convert.toHexString(Crypto.sha256().digest(signature)));
        json.put("fullHash", transaction.getFullHash());
        json.put("transaction", transaction.getStringId());
    }
    else if (!transaction.getType().isSigned()) {
    	json.put("fullHash", transaction.getFullHash());
        json.put("transaction", transaction.getStringId());
    }
    JSONObject attachmentJSON = new JSONObject();
    for (Appendix appendage : transaction.getAppendages()) {
        attachmentJSON.putAll(appendage.getJSONObject());
    }
    if (! attachmentJSON.isEmpty()) {
        modifyAttachmentJSON(attachmentJSON);
        json.put("attachment", attachmentJSON);
    }
    putAccount(json, "sender", transaction.getSenderId());
    json.put("height", transaction.getHeight());
    json.put("version", transaction.getVersion());
    if (transaction.getVersion() > 0) {
        json.put("ecBlockId", Convert.toUnsignedLong(transaction.getECBlockId()));
        json.put("ecBlockHeight", transaction.getECBlockHeight());
    }

    return json;
}
 
開發者ID:muhatzg,項目名稱:burstcoin,代碼行數:45,代碼來源:JSONData.java


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